Web/JavaScript/Reference/Global objects/Number/isFinite
The Number.isFinite() method determines whether the passed value is a finite number — that is, it checks that a number is neither positive nor negative Infinity, since JavaScript has both.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
Number.isFinite(value)
Parameters
value- The value to be tested for finiteness.
Return value
A Boolean indicating whether or not the given value is a finite number.
Description
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.
Examples
Using isFinite
Number.isFinite(Infinity); // false
Number.isFinite(NaN); // false
Number.isFinite(-Infinity); // false
Number.isFinite(0); // true
Number.isFinite(2e64); // true
Number.isFinite('0'); // false, would've been true with
// global isFinite('0')
Number.isFinite(null); // false, would've been true with
// global isFinite(null)
Polyfill
if (Number.isFinite === undefined) Number.isFinite = function(value) {
return typeof value === 'number' && isFinite(value);
}
Specifications
| Specification |
|---|
| ECMAScript (ECMA-262)The definition of 'Number.isInteger' in that specification. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
isFinite
|
Chrome
Full support 19 |
Edge
Full support 12 |
Firefox
Full support 16 |
IE
No support No |
Opera
Full support 15 |
Safari
Full support 9 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 25 |
Firefox Android
Full support 16 |
Opera Android
Full support 14 |
Safari iOS
Full support 9 |
Samsung Internet Android
Full support 1.5 |
nodejs
Full support 0.10 |
Legend
- Full support
- Full support
- No support
- No support
See also
Number.isFinite() by Mozilla Contributors is licensed under CC-BY-SA 2.5.