isFinite
Checks that a value converts to a finite number.
Available since: ES1
Syntax
isFinite(value)Parameters
| Parameter | Type | Description |
|---|---|---|
| value | any | A value; it is converted to a number first. |
Return value
booleantrue if the conversion gives a finite number.
Examples
Strings are converted to numbers:
console.log(isFinite('42'));
console.log(isFinite('abc'));
console.log(isFinite(Infinity));Output:
true
false
falseNotes
Unlike Number.isFinite(), the global function accepts numeric strings. An empty string and null convert to 0 and count as finite.
See also
- Number.isFinite — Checks that a value is a finite number (not NaN and not Infinity).
- isNaN — Checks whether converting a value to a number gives NaN.
In the tutorial
- Numbers — Numbers in JavaScript — integers and fractions, rounding, the Math object, toFixed and the special values Infinity and NaN.