ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

== vs === : Loose vs Strict Equality

One of the most-asked JS interview questions. The short version: always use ===. Here's why loose equality is dangerous.

What each does

=== (strict) compares type and value with no conversion. == (loose) coerces the operands to a common type first, which produces results almost nobody can predict reliably.

0 == "";           // true
0 == "0";          // true
"" == "0";         // false
null == undefined; // true
null === undefined;// false

The one useful == idiom

The only place loose equality earns its keep is `x == null`, which is true for both null and undefined — a concise way to catch both at once. Everywhere else, use ===.

Crack the JS output questions

Coercion, truthiness and the 'what does this print?' traps — all covered with clear reasoning in the JavaScript Interview Kit.

⚡ Get the JavaScript Interview Kit → ₹299

Frequently asked questions

Is === faster than ==?
Marginally, because it skips coercion — but the real reason to prefer it is correctness and predictability, not speed.
What does [] == ![] return?
true — a notorious coercion trick. ![] is false, [] coerces to '', both become 0, so 0 == 0. It's exactly why == is avoided.

Full kit

JavaScript Interview Kit · ₹299

Get it →