Number.isNaN()
Determines whether the passed value is the NaN value.
Syntax
Number.isNaN(value) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to test. |
Returns
boolean — true if the value is exactly NaN; otherwise false.
Examples
console.log(Number.isNaN(NaN), Number.isNaN(0 / 0));
Output
true true
console.log(Number.isNaN('abc'), isNaN('abc'));
Output
false true
Notes
Safer than the global `isNaN`, which coerces its argument (so `isNaN('abc')`
is true). This returns true only for the actual NaN value.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 25 |
| firefox | 15 |
| safari | 9 |
| edge | 12 |
| node | 0.10 |