Our volunteers haven't translated this article into Bamanankan yet. Join us and help get the job done!
You can also read the article in English (US).
The global isFinite() function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.
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
isFinite(testValue)
Parameters
testValue- The value to be tested for finiteness.
Return value
false if the argument is positive or negative Infinity or NaN or undefined; otherwise, true.
Description
isFinite is a top-level function and is not associated with any 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
isFinite(Infinity); // false
isFinite(NaN); // false
isFinite(-Infinity); // false
isFinite(0); // true
isFinite(2e64); // true
isFinite(910); // true
isFinite(null); // true, would've been false with the
// more robust Number.isFinite(null)
isFinite('0'); // true, would've been false with the
// more robust Number.isFinite("0")
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 3rd Edition (ECMA-262) | Standard | Initial definition. |
| ECMAScript 5.1 (ECMA-262) The definition of 'isFinite' in that specification. |
Standard | |
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'isFinite' in that specification. |
Standard | |
| ECMAScript Latest Draft (ECMA-262) The definition of 'isFinite' in that specification. |
Draft |
Browser compatibility
| Desktop | Mobile | Server | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Basic support | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
Legend
- Full support
- Full support