JS Built-ins
NumberNaNintermediate

Number.NaN β€” Number.isNaN vs global isNaN

πŸ“– Usage Example
// Represents Not-a-Number
Number.NaN        // β†’ NaN
Number.isNaN(Number.NaN)  // β†’ true
Number.NaN === Number.NaN // β†’ false (NaN is never equal to itself)

Use Number.NaN as a named constant for Not-a-Number; always check for it with Number.isNaN() since NaN !== NaN.

Number.isNaN vs global isNaN

Number.isNaN() does NOT coerce its argument, while global isNaN() does.

isNaN('hello')        // β†’ true  (coerces 'hello' β†’ NaN first)
Number.isNaN('hello') // β†’ false (no coercion)
πŸ’‘ Hints (1)
  • β€’ Prefer `Number.isNaN()` in modern code to avoid unexpected coercion.