JS Built-ins
TypeCoercionintermediate

NaN Behavior

NaN (Not a Number)

NaN is a special numeric value resulting from invalid operations:

  • Number('abc') is NaN
  • parseInt('x') is NaN
  • 0 / 0 is NaN

Important: NaN !== NaN β€” NaN is the only value not equal to itself!

  • Use Number.isNaN(x) to reliably check for NaN
  • typeof NaN is 'number' (quirk of JavaScript)

Challenge: Verify NaN's unique behavior.

πŸ’‘ Hints (4)
  • β€’ NaN is a special numeric value that does not equal itself.
  • β€’ Always use Number.isNaN() to check for NaN, not === or the global isNaN().
  • β€’ typeof NaN returns "number", which is technically correct but unintuitive.
  • β€’ NaN stands for "Not a Number" but its type is still "number".