isFinite()
The isFinite()
function determines whether the
passed value is a finite number. If needed, the parameter is first converted to a
number.
Try it
Syntax
js
isFinite(testValue)
Parameters
testValue
-
The value to be tested for finiteness.
Return value
Description
isFinite
is a function property of the global object.
You can use this function to determine whether a number is a finite number. The
isFinite
function examines the number in its argument. If the argument is
NaN
, positive infinity, or negative infinity, this method returns
false
; otherwise, it returns true
.
Examples
Using isFinite
js
isFinite(Infinity); // false
isFinite(NaN); // false
isFinite(-Infinity); // false
isFinite(0); // true
isFinite(2e64); // true
isFinite(910); // true
// Would've been false with the more robust Number.isFinite():
isFinite(null); // true
isFinite("0"); // true
Specifications
Specification |
---|
ECMAScript Language Specification # sec-isfinite-number |
Browser compatibility
BCD tables only load in the browser