JavaScript isNaN() function

Definition and usage

isNaN() The function can determine whether the value is a non-numeric (Not-a-Number).

If the value equals NaN, this function returns true. Otherwise, it returns false.

This function is different from the Number-specific Number.isNaN() method.

The global isNaN() function converts the value to a number and then tests it.

The Number.isNaN() method does not convert the value to a number and does not return true for any non-numeric types.

Example

Check if the value is NaN:

isNaN(123) //false
isNaN(-1.23) //false
isNaN(5-2) //false
isNaN(0) //false
isNaN('123') //false
isNaN('Hello') //true
isNaN('2005/12/12') //true
isNaN('') //false
isNaN(true) //false
isNaN(undefined) //true
isNaN('NaN') //true
isNaN(NaN) //true
isNaN(0 / 0) //true
isNaN(null) //false

Try it yourself

Syntax

isNaN(value)

Parameter value

Parameter Description
value Required. The value to be tested.

Technical details

Return value: Boolean value. If the value is NaN, it returns true, otherwise it returns false.
JavaScript Version: ECMAScript 1

Browser Support

Function Chrome Edge Firefox Safari Opera
isNaN() Support Support Support Support Support