Skip to content

finite

Whether a value is a finite number: not NaN, ±Infinity, or a non-number such as a numeric string, null, or an array.

True only for a number that is not NaN or infinite. A numeric string is not a number, so "3" is false; in TypeScript it also narrows the value to number.

import {finite} from "@d3plus/math";

finite(0);
finite(-2.5);
finite(NaN);
finite(Infinity);
finite("3");
finite(null);

Parameters

import {finite} from "@d3plus/math";
valuerequiredunknown

The value to check.