The isFinite() function checks whether the passed value is a finite number.
Example
isFinite() Syntax
The syntax of the isFinite() function is:
isFinite(testValue)
isFinite() Parameters
The isFinite() function takes in:
- testValue - value to be tested for finiteness.
isFinite() Return Value
The isFinite() function returns
false- if the argument isInfinityorNaNorundefinedtrue- for all other arguments
Example 1: JavaScript isFinite()
In the above example, we have used isFinite() to check whether the given value is finite or not. The output is true, as 5463 is a finite number.
Example 2: isFinite() With Infinity and undefined
Example 3: isFinite() With NaN and null
Note: In JavaScript, isFinite() is a top-level function because it is not associated with any object or class, and we can call it from anywhere without creating an instance.
Recommended Reading: