NaN property is a value representing Not-A-Number.
The same number value as
NaN is a property of the global object. In other words, it is a variable in global scope.
In modern browsers,
NaN is a non-configurable, non-writable property. Even when this is not the case, avoid overriding it.
There are five different types of operations that return
- Failed number conversion (e.g. explicit ones like
Number(undefined), or implicit ones like
- Math operation where the result is not a real number (e.g.
- Indeterminate form (e.g.
0 * Infinity,
1 ** Infinity,
Infinity / Infinity,
Infinity - Infinity)
- A method or expression whose operand is or gets coerced to
7 ** NaN,
7 * "blabla") — this means
- Other cases where an invalid value is to be represented as a number (e.g. an invalid
NaN !== NaN) are specified by IEEE 754.
NaN's behaviors include:
NaNis involved in a mathematical operation (but not bitwise operations), the result is usually also
NaN. (See counter-example below.)
NaNis one of the operands of any relational comparison (
<=), the result is always
NaNcompares unequal (via
!==) to any other value — including to another