Interview Hub
Sign in

Q3: `==` vs `===` — when does it matter?

EasyJavaScript 29

Answer

=== checks value and type without coercion. == applies abstract equality conversion (e.g. 0 == false). In application code, default to === to avoid surprises; know == rules for reading legacy code and for null/undefined checks (x == null matches both, sometimes used intentionally).

Having a tech or coding interview? Check 29 JavaScript & Node.js interview questions.

Source: MDN — Equality comparisons

EditorJavaScript · local only