全局
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.
isFinite(testValue)
testValue
The value to be tested for finiteness.
false
if the argument is positive or negative
Infinity
or
NaN
or
undefined
; otherwise,
true
.
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
.
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")
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'isFinite' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
isFinite
|
Chrome 1 | Edge 12 | Firefox 1 | IE 4 | Opera 3 | Safari 1 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 1 | Samsung Internet Android 1.0 | nodejs 0.1.100 |
完整支持