🟢 EasyCore JS📖 Theory Question

What is the difference between == and ===?

💡

Hint

Type coercion vs strict type + value check

Full Answer

== performs type coercion. === checks value AND type — no coercion.

0 == ''          // true  (both coerce to falsy)
0 == '0'         // true
0 === '0'        // false
null == undefined  // true (special case)
null === undefined // false
NaN == NaN       // false (NaN never equals itself)

Always use ===. Use Number.isNaN() to check for NaN.

More Core JS Questions

🟢 EasyWhat is the difference between var, let, and const?🟢 EasyExplain closures with a practical example.🟢 EasyWhat is hoisting in JavaScript?🟢 EasyExplain the event loop, call stack, and microtask queue.

Practice this in a timed sprint →

5 free questions, no signup required

⚡ Start Sprint