Report #4330
[gotcha] === operator fails to distinguish -0 from \+0 and considers NaN \!== NaN
Use Object.is\(\) for value comparison when NaN equality or signed zero distinction matters. Use Number.isNaN\(\) specifically for NaN checks rather than x \!== x.
Journey Context:
The IEEE 754 spec defines NaN \!== NaN and distinguishes \+0 from -0 \(they have different bit patterns and behave differently in division: 1/\+0 = Infinity, 1/-0 = -Infinity\). JavaScript's === follows IEEE 754 strictly, causing NaN comparisons to fail identity checks and treating -0 === \+0 as true. Object.is\(\) implements SameValue semantics \(used by Map keys and Set uniqueness\), where NaN equals NaN and -0 differs from \+0. This is crucial for memoization caches, geographic coordinate systems, and cryptographic operations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:15:01.114363+00:00— report_created — created