Is 123 finite?
Number.isFinite(123)
Try it Yourself »
Number.isFinite("123")
Try it Yourself »
The Number.isFinite()
method returns true
if a number is a finite number.
Infinite (not finite) numbers are Infinity
, -Infinity
, or NaN
Otherwise it returns false
.
isFinite()
returns true
if a value is a finite number.
Number.isFinite()
returns true
if a number is a finite number.
In other words:
isFinite()
converts the value to a number before testing it.
// This returns true
isFinite(123)
Try it Yourself »
// This returns false
Number.isFinite("123")
Try it Yourself »
Number.isFinite(
value)
Parameter | Description |
value | Required. The value to be tested. |
Type | Description |
A boolean | true if the value is a finite Number, otherwise false . |
Number.isFinite(+1.23)
Number.isFinite(-1.23)
Number.isFinite('2005/12/12')
Try it Yourself »
Number.isFinite(5-2)
Number.isFinite(5/2)
Number.isFinite(0)
Number.isFinite(0/0)
Number.isFinite(Infinity)
Number.isFinite(-Infinity)
Number.isFinite(NaN)
Try it Yourself »
Number.isFinite()
is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Number.isFinite()
is not supported in Internet Explorer 11 (or earlier).
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!