JavaScriptEasy
What's the difference between == and ===?
Explain the difference between == and === in JavaScript. Which do you use, and why?
Answer out loud (or ask the AI tutor to play interviewer) before revealing the model answer.
Reveal model answer
Model answer
===is strict equality: true only if both value and type are the same.==is loose equality: it converts (coerces) types before comparing.
5 === "5"; // false: number vs string
5 == "5"; // true: "5" is converted to 5
0 == false; // true
null == undefined; // true
null === undefined; // false
What I use: === almost always, because coercion rules cause surprising bugs and make code harder to reason about. Many teams enforce it with a linter rule (eqeqeq).
Bonus point: the one common exception is value == null, which checks for both null and undefined at once. Some codebases allow it deliberately.
Why interviewers ask: it checks whether you understand types and coercion, not just syntax.