The Javascript Number.isFinite()
method checks if the passed value is a finite number.
Number.isFinite(value)
Parameter | Optional | Meaning |
---|---|---|
value | Required | The value to be tested. |
It returns a boolean value indicating whether or not the given value is a finite number.
Unlike global isFinite()
function, this method doesn't convert the parameter to a number.
It returns true for the finite number only.
let a = Number.isFinite(Infinity); // false a = Number.isFinite(NaN); // false console.log(a);// w ww .j a v a 2 s . c om a = Number.isFinite(-Infinity); // false console.log(a); a = Number.isFinite(0); // true console.log(a); a = Number.isFinite(2e64); // true console.log(a); a = Number.isFinite('0'); // false, true with global isFinite('0') console.log(a); a = Number.isFinite(null); // false, true with global isFinite(null) console.log(a);