The isNaN() function checks if a value is NaN (Not-a-Number) or not.
Example
isNaN() Syntax
The syntax of the isNaN() function is:
isNaN(value)
isNaN() Parameters
The isNaN() function takes in:
- value - The value to be tested.
isNaN() Return Value
- Returns
trueif the argument isNaN. - Returns
falsefor other arguments.
Example: Using isNaN()
Output
true true false false false true false false true
Notes:
isNaN()is a top-level function and is not associated with any object.- If the argument is not of type
Number, the value is first coerced toNaNand then checked.
Recommended Reading: Javascript isFinite()