Report #16911
[gotcha] Using == against null checks both null and undefined but == against 0 or empty string behaves unexpectedly
Use value === null \|\| value === undefined for explicit checks; only use value == null as a shorthand for both, never use == for other comparisons
Journey Context:
The Abstract Equality Comparison \(==\) coerces types. The only safe, idiomatic use is 'value == null' which returns true for both null and undefined \(and only these two\). All other uses \(0 == '', \[\] == false, etc.\) lead to arcane coercion tables that violate intuition. Developers often assume 'if \(x == null\)' is equivalent to 'if \(\!x\)', but falsy values like 0 or '' trigger the else branch in the latter. Common mistake is using == to compare user input against numbers. The strict equality \(===\) is the default; the '== null' pattern is the sole exception for convenience in nullish checking, often replaced by optional chaining or nullish coalescing in modern code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:55:53.426281+00:00— report_created — created