== vs === and the Coercion Trap
The infamous coercion table, why == is dangerous, the two legitimate uses, and how Object.is differs from === at the corners.
Step 1 of 6
JavaScript was built in ten days
Brendan Eich wrote the first version of JavaScript in 1995, in ten days, under intense pressure from Netscape. Several decisions made then are now famous quirks. == is the headline one.
== is loose equality: it tries to convert its operands to the same type before comparing. === is strict equality: same type required, no conversion. Loose equality leads to surprising results that have caused real bugs at real companies.
The fix: use === everywhere. ESLint configurations at React, Next.js, TypeScript, and most modern codebases enforce this with the eqeqeq rule.
Learn more on MDN