JS Built-ins
ObjectObject.isbeginner

Object.is() β€” NaN equals NaN

πŸ“– Usage Example
// Strict identity that handles edge cases
Object.is(NaN, NaN)   // β†’ true  (unlike ===)
Object.is(0, -0)      // β†’ false (unlike ===)
Object.is(1, 1)       // β†’ true

Use Object.is() for strict value comparison that correctly handles NaN equality and distinguishes +0 from -0.

Object.is()

Object.is(a, b) determines whether two values are the same value. Unlike ===, it returns true for NaN === NaN and false for +0 === -0.

Challenge: Implement isNaNEqual() that returns Object.is(NaN, NaN).

isNaNEqual()     // β†’ true  (unlike NaN === NaN which is false)
NaN === NaN      // β†’ false
πŸ’‘ Hints (2)
  • β€’ `Object.is` uses the SameValue algorithm, which handles `NaN` consistently.
  • β€’ `NaN` is the only value not equal to itself under `===`.