A seemingly minor JavaScript operator mix-up led to a production outage where all user avatars failed to load. The developer used `||` instead of `??`, causing falsy values like empty strings to be replaced, breaking image URLs. This incident underscores the importance of understanding the difference between the logical OR (`||`) and nullish coalescing (`??`) operators. `||` returns the right-hand operand for any falsy value (0, '', false, null, undefined), while `??` only does so for null or undefined. The bug was caught after user reports, and the fix was a single character change. For engineering teams, this is a strong reminder to adopt ESLint rules like `no-unsafe-optional-chaining` and to include operator-specific checks in code reviews. The story has resonated widely on Chinese developer forums, sparking discussions on defensive coding and testing edge cases.
A developer accidentally used `||` instead of `??` in JavaScript, causing all user avatars to fail in production. This highlights the critical difference between nullish coalescing and logical OR operators. The story serves as a practical warning for teams to enforce stricter linting and code review practices.