JavaScript isFinite()
Examples
Check if a number is finite:
let result = isFinite(123);
Try it Yourself »
let result = isFinite("123");
Try it Yourself »
Description
The isFinite()
method returns true
if a value is a finite number.
Infinite (not finite) values are Infinity
,
-Infinity
, or NaN
See Also:
Difference Between isFinite() and Number.isFinite()
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.
Examples
// This returns true
isFinite(123)
Try it Yourself »
// This returns false
Number.isFinite("123")
Try it Yourself »
Syntax
isFinite(value)
Parameters
Parameter | Description |
value | Required. The value to be tested. |
Return Value
Type | Description |
A boolean. | false if the value is Infinity,
-Infinity, or NaN.Otherwise true . |
More Examples
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 »
Browser Support
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 |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.