Skip to main content

isNumber() function

Determines whether a value is a finite number.

Signature

export declare function isNumber(value: unknown): boolean;

Parameters

Parameter

Type

Description

value

unknown

The value to test.

Returns

boolean

true if the value is a finite number, false otherwise.

Remarks

This function validates that a value is both a number type and mathematically finite, excluding NaN, Infinity, and -Infinity. This is essential when validating numeric configuration values or processing JSON data where numeric fields must contain valid, computable values.

Returns true for: all finite numeric values, including 0, negative numbers, and floating-point numbers.

Returns false for: NaN, Infinity, -Infinity, strings, objects, arrays, and any non-number types.

Only returns true for primitive number values, not Number objects created with new Number().

The finiteness check is crucial for mathematical operations and ensures that numeric properties in package.json or configuration files contain usable values rather than special numeric constants that could cause unexpected behaviour in calculations.


Generated via tsdoc2docusaurus 1.3.0-pre by API Extractor/Documenter 7.55.2.