Report #17286
[gotcha] Memoization cache keys using === conflate -0 with \+0 and fail to match NaN with itself
Use Object.is\(\) for key comparison in memoization logic, or normalize inputs \(coerce -0 to 0, use Number.isNaN checks\) before storing/retrieving from cache
Journey Context:
Developers assume === handles all primitives consistently. However, -0 === \+0 returns true \(failing to distinguish infinities in division\) while NaN === NaN is false. Memoization libraries using Map/Set with === keys will conflate -0 and \+0 \(causing division direction bugs\) and fail to retrieve cached NaN results. Object.is\(\) is the only built-in that correctly differentiates -0/\+0 and treats NaN as equal to itself, making it the correct choice for robust memoization keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:54:45.698665+00:00— report_created — created