Report #12788
[gotcha] === treats NaN as not equal to NaN and \+0 as equal to -0, breaking cache keys
Use Object.is\(\) for memoization key comparison \(or Maps/Sets which use SameValueZero, similar to Object.is but treats \+0/-0 as equal\) to handle NaN and signed zero correctly.
Journey Context:
Developers implementing custom memoization or deduplication logic rely on === or == for key comparison. However, per ECMAScript's SameValue algorithm \(used by Object.is\), NaN is equal to NaN \(unlike ===\), and \+0 is not equal to -0 \(unlike === where they are equal\). This causes subtle bugs: memoization caches fail to retrieve entries keyed by NaN calculations, or deduplication logic fails to distinguish between \+0 and -0 in mathematical contexts where signed zero matters \(e.g., atan2\). Map and Set use SameValueZero \(like SameValue but \+0 equals -0\), which is usually the desired behavior for collections.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:54:05.890554+00:00— report_created — created