Javascript isNaN()

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 true if the argument is NaN.
  • Returns false for 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 to NaN and then checked.

Recommended Reading: Javascript isFinite()