Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
The Number.isNaN() static method determines whether the passed value is the number value NaN, and returns false if the input is not of the Number type. It is a more robust version of the original, global isNaN() function.
The value to be tested for NaN.
The boolean value true if the given value is a number with value NaN. Otherwise, false.
The function Number.isNaN() provides a convenient way to check for equality with NaN. Note that you cannot test for equality with NaN using either the == or === operators, because unlike all other value comparisons in JavaScript, these evaluate to false whenever one operand is NaN, even if the other operand is also NaN.
Since x !== x is only true for NaN among all possible JavaScript values, Number.isNaN(x) can also be replaced with a test for x !== x, despite the latter being less readable.
As opposed to the global isNaN() function, the Number.isNaN() method doesn't force-convert the parameter to a number. This makes it safe to pass values that would normally convert to NaN but aren't actually the same value as NaN. This also means that only values of the Number type that are also NaN return true.
Number.isNaN() doesn't attempt to convert the parameter to a number, so non-numbers always return false. The following are all false:
The global isNaN() coerces its parameter to a number:
| ECMAScript® 2027 Language Specification # sec-number.isnan |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 10, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.