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

Prepare · Practice · Crack

Tricky JavaScript Interview Questions

These are the questions designed to trip you up. Know the reasoning and they become easy.

Why is 0.1 + 0.2 not equal to 0.3?

All JS numbers are 64-bit floats; 0.1 and 0.2 can't be represented exactly in binary, so the sum is 0.30000000000000004. Compare floats within Number.EPSILON or work in integers.

Why is NaN not equal to itself?

NaN === NaN is false by design — it's the only value not equal to itself. Use Number.isNaN(x) to test for it.

What does typeof null return, and why?

'object' — a historic bug kept for backward compatibility. The only reliable null check is x === null.

What prints: closures in a loop?

var shares one binding, so deferred callbacks read the final value (3 3 3); let creates a fresh binding per iteration (0 1 2).

What is the output of promise vs setTimeout?

Sync first, then microtasks (promises), then macrotasks (setTimeout) — so a .then always beats a 0ms setTimeout.

Beat every JavaScript trap

Coercion, floating point, the event loop and output traps — all explained with the reasoning in the JavaScript Interview Kit.

⚡ Get the JavaScript Interview Kit → ₹299

Frequently asked questions

How do I prepare for tricky JS questions?
Learn the underlying models — floating point, coercion, the event loop, closures — instead of memorising individual answers.
Are these actually asked?
Yes, frequently — they're quick to pose and reveal whether you truly understand JavaScript.

Full kit

JavaScript Interview Kit · ₹299

Get it →