Perfect Equality
There is an Object.is(a, b) method that works almost like ===, but is " smarter " in two specific cases.
1. The NaN Case
In JavaScript, NaN is the only value that doesn't equal itself: NaN === NaN yields false.
alert( Object.is(NaN, NaN) ); // true (the only way to verify NaN equality)
2. The Zero Case (-0 and +0)
In math and computer memory, there is a " negative zero " .
0 === -0; // true
Object.is(0, -0); // false (they are technically different in memory)
Note
In 99.9% of cases, the regular === is exactly what you need. Object.is is used in JS internal algorithms (e.g., comparing keys in Map/Set).
Tip
For standard NaN checks, it's easier to use Number.isNaN(value).