Number.isFinite
Determines whether the passed value is a finite number — not Infinity, -Infinity, or NaN
Syntax
Number.isFinite(value)Parameters
| Parameter | Type | Description |
|---|---|---|
| value | any | The value to be tested |
Return Value
true if the value is a finite number, false otherwise
Examples
console.log(Number.isFinite(42)); // true
console.log(Number.isFinite(Infinity)); // false
console.log(Number.isFinite(NaN)); // falseconsole.log(Number.isFinite('42')); // false (unlike global isFinite)
console.log(isFinite('42' as any)); // truefunction safeDiv(a: number, b: number) {
const result = a / b;
return Number.isFinite(result) ? result : 0;
}
console.log(safeDiv(10, 0)); // 0Understanding Number.isFinite
The Number.isFinite method in JavaScript determines whether the passed value is a finite number — not Infinity, -Infinity, or NaN. It belongs to the Number object and is one of the most widely used methods for working with number values in modern JavaScript and TypeScript applications.
The method signature is Number.isFinite(value). It accepts 1 parameter: value. When called, it returns true if the value is a finite number, false otherwise. Understanding when and how to use isFinite() helps you write more expressive, readable code.
Common use cases for Number.isFinite include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like number-isnan, number-isinteger, number-issafeinteger, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Number.isFinite is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Number.isNaNDetermines whether the passed value is NaN and its type is Number, providing a more robust version of the original global isNaN()
Number.isIntegerDetermines whether the passed value is an integer
Number.isSafeIntegerDetermines whether the provided value is a number that is a safe integer, meaning it can be exactly represented as a double-precision floating-point number
More Number Methods
Other methods in the Number object
Related Tools
More Number Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.