Report #102915
[gotcha] == vs ===: '\\t\\n' == 0 returns true, because empty string coercion to number is 0
Always use === \(strict equality\) unless you explicitly need type coercion. For checking empty strings, use str === '' or str.length === 0. Never rely on == for falsy checks.
Journey Context:
The == operator performs type coercion using the Abstract Equality Comparison algorithm. A string containing only whitespace \(spaces, tabs, newlines\) coerces to 0 via ToNumber, which first calls ToPrimitive then ToNumber on the string. The string '\\t\\n' has no numeric content, so ToNumber returns 0. This means '\\t\\n' == 0 is true, and '\\t\\n' == false is also true \(since false coerces to 0\). This is a classic footgun because whitespace-only strings appear empty but are not falsy in the usual sense. The fix is always ===, which avoids coercion entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T15:53:34.462434+00:00— report_created — created