JavaScript: NaN

By Xah Lee. Date: . Last updated: .

NaN is the value of the property key "NaN" of the Global Object.

console.log( Number.isNaN( window["NaN"] ) ); // true

NaN is a literal value. For example, you can write let x = NaN;

NaN means โ€œNot a Numberโ€. It is typically returned when converting a value to number that doesn't make sense.

// convert string to number
// if arg does not make sense, result is NaN
console.log( Number.isNaN( Number( "xyz") ) ); // true

[see Number Constructor]

Type of NaN is "number".

console.log( typeof NaN === "number" ); // true

NaN === NaN return false.

console.log( NaN === NaN ); // false

To test equality of NaN, use .

To test if a value is NaN, use Number.isNaN.

JavaScript Special Literals

JavaScript in Depth

JS Obj Reference

Global Object

Special Objects

Static Objects

Primitive Wrapper

Constant Literals

Simple Functions

Error Objects