THE WORLD'S LARGEST WEB DEVELOPER SITE

JavaScript Number isNaN() Method

❮ JavaScript Number Reference

Example

Check whether a value is NaN:

Number.isNaN(123) //false
Number.isNaN(-1.23) //false
Number.isNaN(5-2) //false
Number.isNaN(0) //false
Number.isNaN('123') //false
Number.isNaN('Hello') //false
Number.isNaN('2005/12/12') //false
Number.isNaN('') //false
Number.isNaN(true) //false
Number.isNaN(undefined) //false
Number.isNaN('NaN') //false
Number.isNaN(NaN) //true
Number.isNaN(0 / 0) //true
Try it Yourself »

Definition and Usage

The Number.isNaN() method determines whether a value is NaN (Not-A-Number).

This method returns true if the value is of the type Number, and equates to NaN. Otherwise it returns false.

Number.isNaN() is different from the global isNaN() function. The global isNaN() function converts the tested value to a Number, then tests it.

Number.isNaN() does not convert the values to a Number, and will not return true for any value that is not of the type Number.

Tip: In JavaScript, the value NaN is considered a type of number.


Browser Support

Method
Number.isNaN() Yes 12.0 32 9 22

Syntax

Number.isNaN(value)

Parameter Values

Parameter Description
value Required. The value to be tested

Technical Details

Return Value: A Boolean. Returns true if the value is Number.NaN, otherwise it returns false
JavaScript Version: ECMAScript 6

❮ JavaScript Number Reference