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]


Number Topic

  1. JS: Format Number
  2. JS: String to Number
  3. JS: Number Object
  4. JS: Number Constructor
  5. JS: Number.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

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

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Reference
  5. DOM
  6. SVG
  7. Web Dev Blog