isFinite()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
TheisFinite() function determines whether a value is finite, first converting the value to a number if necessary. A finite number is one that's notNaN or ±Infinity. Because coercion inside theisFinite() function can besurprising, you may prefer to useNumber.isFinite().
In this article
Try it
function div(x) { if (isFinite(1000 / x)) { return "Number is NOT Infinity."; } return "Number is Infinity!";}console.log(div(0));// Expected output: "Number is Infinity!""console.log(div(1));// Expected output: "Number is NOT Infinity."Syntax
isFinite(value)Parameters
valueThe value to be tested.
Return value
false if the given value isNaN,Infinity, or-Infinity after beingconverted to a number; otherwise,true.
Description
isFinite() is a function property of the global object.
When the argument to theisFinite() function is not of typeNumber, the value is first coerced to a number, and the resulting value is then compared againstNaN and ±Infinity. This is as confusing as the behavior ofisNaN — for example,isFinite("1") istrue.
Number.isFinite() is a more reliable way to test whether a value is a finite number value, because it returnsfalse for any non-number input.
Examples
>Using isFinite()
isFinite(Infinity); // falseisFinite(NaN); // falseisFinite(-Infinity); // falseisFinite(0); // trueisFinite(2e64); // trueisFinite(910); // true// Would've been false with the more robust Number.isFinite():isFinite(null); // trueisFinite("0"); // trueSpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-isfinite-number> |