By Xah Lee. Date: .

NaN is a primitive value that means “Not a Number”.

NaN 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 ("xyz")  ); // NaN

[see JS: Number Constructor]

Type of NaN is "number".

[see JS: Value Types]

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

NaN === NaN return false.

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

To test if a value is NaN, use Number.isNaN or the global function isNaN.

[see JS: Number.isNaN]

[see JS: isNaN]


JS Number

  1. Format Number
  2. String to Number
  3. Random Number

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials