JavaScript Interview Questions

43 JavaScript interview questions with worked answers, complexity notes, and runnable code you can edit in the browser — ordered easy to hard so you build up steadily. Free, no signup. Open any question for the full answer.

The runtime, not the syntax

Anyone can recite that JavaScript is single-threaded; the interview finds out whether you know what that buys you and what it costs. The event loop is the center of gravity — the call stack runs to completion, then the microtask queue (promises) drains fully, then one macrotask (a timer, an event) runs, and the cycle repeats. Half the “what logs first?” puzzles are just this ordering, and once you can trace it by hand they stop being tricks.

Closures are the other load-bearing concept. A function keeps a live reference to the scope it was defined in, which is how you get private state, memoization, and every “implement once” variant. The classic senior filter — build debounce, throttle, deepClone, or Promise.all from scratch — is really a closure-and-async test wearing a utility’s clothing: it checks that you can hold state across calls, handle the edge cases (leading vs trailing, empty input, rejection), and reason about timing.

Then there is this, which is decided by how a function is called, not where it is written — the source of most confusion and most bugs, and the reason arrow functions (which capture this lexically) exist. Prototypes explain inheritance and why class is sugar over the same chain. Coercion explains the surprising equality results. The questions here work up from these fundamentals into the from-scratch implementations, because that is exactly the arc a strong JavaScript interview follows.

Easy

Medium

Hard

Other topics

HTML/CSS · Browser · TypeScript · React · System Design · Accessibility · Web Performance · Testing · Networking/Security · DSA

← Search all 265 questions