Baseline Widely available
The Number.isFinite()
static method determines whether the passed value is a finite number â that is, it checks that a given value is a number, and the number is neither positive Infinity
, negative Infinity
, nor NaN
.
console.log(Number.isFinite(1 / 0));
// Expected output: false
console.log(Number.isFinite(10 / 5));
// Expected output: true
console.log(Number.isFinite(0 / 0));
// Expected output: false
Syntax Parameters
value
The value to be tested for finiteness.
The boolean value true
if the given value is a finite number. Otherwise false
.
Number.isFinite(Infinity); // false
Number.isFinite(NaN); // false
Number.isFinite(-Infinity); // false
Number.isFinite(0); // true
Number.isFinite(2e64); // true
Difference between Number.isFinite() and global isFinite()
In comparison to the global isFinite()
function, this method doesn't first convert the parameter to a number. This means only values of the type number and are finite return true
, and non-numbers always return false
.
isFinite("0"); // true; coerced to number 0
Number.isFinite("0"); // false
isFinite(null); // true; coerced to number 0
Number.isFinite(null); // false
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4