Report #103019
[gotcha] Why does \[\] == \!\[\] evaluate to true, and when is == ever safe to use?
Always prefer === and \!==. The only widely accepted exception is x == null as a shorthand for x === null \|\| x === undefined, and only when the intent is clearly documented. Never use == with objects, arrays, booleans, or mixed types.
Journey Context:
The Abstract Equality Comparison algorithm performs a surprising sequence of coercions: \[\] == \!\[\] becomes \[\] == false, then \[\] == 0, then '' == 0, then 0 == 0, which is true. The operator is not transitive: 0 == '', 0 == '0', but '' \!= '0'. Strict equality \(===\) compares value and type without coercion, producing predictable results. Some code bases allow x == null because null == undefined is true while null == 0 is false, making it a concise nullish check, but this is the lone exception and should be flagged in code review.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-10T04:52:50.496635+00:00— report_created — created