Report #9325
[gotcha] Loose equality \(==\) allows type coercion producing counter-intuitive results like \[\] == false, '' == false, and null >= 0 being true while null > 0 is false
Always use strict equality \(=== and \!==\) for comparisons; if checking for null or undefined, use x == null \(covers both\) or explicit x === null \|\| x === undefined, never rely on truthy/falsy coercion for business logic
Journey Context:
The Abstract Equality Comparison algorithm in ECMA-262 performs type coercion when operands differ. This leads to surprising results: empty array \[\] becomes empty string "" then number 0, making \[\] == false true. Similarly, null becomes 0 in numeric context, so null >= 0 is true, but null > 0 is false because 0 > 0 is false. These inconsistencies cause subtle bugs in conditionals and range checks. The only safe path is strict equality \(===\), which checks both value and type without coercion. The one idiomatic exception is x == null, which is a concise, reliable check for both null and undefined without risking other falsy values like 0 or "".
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:49:55.257323+00:00— report_created — created