JavaScript Number.isNaN() Method
The Number.isNaN() static method checks whether a value is NaN, without the confusing type conversion of the global isNaN().
Description
The Number.isNaN() static method returns true only if the value is NaN. It's needed because NaN isn't equal to anything, even itself, so x === NaN never works. The global isNaN() converts its argument to a number first, so isNaN('hello') is true; Number.isNaN('hello') is false.
NaN shows up when a calculation or conversion fails, such as Number('abc'), parseInt('px'), Math.sqrt(-1) or 0 / 0. Because it spreads through any arithmetic it's involved in, checking for it as soon as a value is converted stops it from quietly breaking later calculations.
Object.is(value, NaN) also detects it, and value !== value is an old trick that works because NaN is the only value not equal to itself. Like other static members of Number, it is called on the Number constructor itself, not on individual number values.
Syntax
Number.isNaN(value)Parameters
- valueThe value to check.
Return Value
true if the value is NaN, otherwise false.
Example
Browser Support
The following information will show you the current browser support for the Number.isNaN() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





