CKTIS / JavaScript
Number.NaN: the Number “not-a-number” value
Number.NaN is the special Number value for an invalid or indeterminate numeric result and is the same value as global NaN.
Version: ECMAScript 1 onward; example target: Node.js 24.22.2
Syntax
Number.NaNNumber.NaN is the NaN value of Number type, identical to global NaN. It can arise from a failed numeric conversion or an operation such as 0 / 0. It is not an exception, and reading the property does not throw; many subsequent numeric operations involving NaN also produce NaN.
NaN is the only JavaScript value unequal to itself under both == and ===, so value === Number.NaN is always false. Test with coercion-free Number.isNaN(value) or Object.is(value, Number.NaN). typeof Number.NaN is "number"; ordered comparisons with NaN are false, and JSON.stringify writes NaN in arrays and object properties as null.
The property has existed since ECMAScript 1 and is non-writable, non-enumerable, and non-configurable. The example returns Number.NaN as an explicit failed-reading parse result and contrasts correct and incorrect tests. A distinct error result is often clearer in a public API because NaN can silently spread through calculations or change meaning during serialization.
Global NaN is a property of the global object with the same Number value as Number.NaN; an identity comparison between them with === is still false because every NaN value is unequal to itself. The global property is non-writable, non-enumerable, and non-configurable, but the NaN identifier can be shadowed by a local binding, so Number.NaN can be less ambiguous. In the source lesson an empty age is explicitly converted to global NaN and then rejected by Number.isInteger().
Examples
function parseMeasurement(text) {
const value = Number(text);
return Number.isNaN(value) ? Number.NaN : value;
}
const failed = parseMeasurement("bad");
console.log(Number.isNaN(failed), failed === Number.NaN, Object.is(failed, Number.NaN));
console.log(typeof Number.NaN, Number.NaN === NaN);
console.log(JSON.stringify({ value: Number.NaN }));
const descriptor = Object.getOwnPropertyDescriptor(Number, "NaN");
console.log(descriptor.writable, descriptor.enumerable, descriptor.configurable);Result
true false true
number false
{"value":null}
false false falseNumber.NaN → an explicit failure result and correct NaN testing