#19: -0 === 0 vs Object.is(-0, 0)
Topic: numbers · Difficulty: ★★★
console.log(-0 === 0);
console.log(Object.is(-0, 0));
console.log(1 / -0);Output
true false -Infinity
Why
IEEE-754 doubles have distinct bit patterns for +0 and -0, but the == and === operators special-case numeric zero comparisons to treat them as identical, so -0 === 0 is true. Object.is implements the stricter SameValue algorithm (used internally for things like Map keys) and does NOT special-case zero, so it correctly reports them as different values: false. The sign is not just theoretical — dividing 1 by -0 produces -Infinity instead of Infinity, revealing which zero you actually have.