Report #104296
[gotcha] == operator coerces object wrappers to primitives, so new Number\(2\) == 2 is true but new Number\(2\) === 2 is false, and NaN == NaN is false
Use === for all comparisons unless you explicitly need coercion. Use Object.is\(\) for NaN equality checks. Avoid using == with object wrappers. For deep equality, use libraries like Lodash.isEqual.
Journey Context:
The == operator performs type coercion which can lead to surprising results. For example, new Number\(2\) is an object, and == coerces it to the primitive value 2. But === does not coerce, so it's false. Also, NaN == NaN is false, NaN === NaN is false, but Object.is\(NaN, NaN\) is true. The safest practice is to avoid == entirely and use ===. For cases where you need to compare two values that might be NaN, use Number.isNaN\(\) separately. The tradeoff is that Object.is is slightly slower but more accurate. Many developers are aware of == vs === but still trip on object wrappers or NaN.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-26T20:05:45.839515+00:00— report_created — created