Check if a number is finite:
let result = isFinite(123);
Try it Yourself »
let result = isFinite("123");
Try it Yourself »
The isFinite()
method returns true
if a value is a finite number.
Infinite (not finite) values are Infinity
, -Infinity
, or NaN
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 »
isFinite(
value)
Parameter | Description |
value | Required. The value to be tested. |
Type | Description |
A boolean. | false if the value is Infinity, -Infinity, or NaN.Otherwise true . |
Check if a number is finite:
isFinite(-1.23);
isFinite(5-2);
isFinite(0);
Try it Yourself »
isFinite("Hello");
isFinite("2005/12/12");
Try it Yourself »
isFinite()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!