isNaN
Using
This function determines whether the given value is the special NaN value (Not-a-Number).
- Returns
trueonly if the value is the primitiveNaN. - Returns
falsefor all other values, including anything that is not strictly theNaNprimitive.
Unlike the global isNaN() function, this version avoids type coercion.
Demo - use JSON
isNaN( )false
Arguments
| Argument | Type | Description | Example |
|---|---|---|---|
value | unknown | Can be any type | "text" 2 undefined |
Returns
boolean — true if value is primitive NaN, false otherwise
Examples
isNaN(NaN);
// true
isNaN(0 / 0);
// true
isNaN(Number('abc'));
// true
isNaN('NaN');
// false
isNaN(42);
// false
isNaN(new Number(NaN));
// false
isNaN(() => NaN);
// false