Clarify checklist
- Should the first call fire immediately or only after the quiet period?
- Should the returned function expose
cancelorflush? - Should the wrapper preserve
this, arguments, and return value?
Use this JavaScript coding interview map to choose high-frequency async, closure, promise, DOM, and utility-function drills, then move into direct FrontendAtlas practice links.
This page is not another JavaScript Q&A dump. Use it as a practice map for the frontend JavaScript coding interview questions that engineers are asked to implement, trace, and explain under time pressure.
The companion JavaScript interview questions hub covers short-answer concept review. This guide points you to direct drills, edge cases, and worked examples so you can turn those concepts into interview-ready reps.
These are the patterns that show up repeatedly because they test real frontend work: timers, async composition, data shaping, browser events, identity, and edge-case discipline.
Requirement: delay execution until calls stop for a quiet period.
Test focus: last args, context, cancellation, leading/trailing policy.
Requirement: run at most once per window while high-frequency events continue.
Test focus: leading call, trailing call, dropped events, timer cleanup.
Requirement: resolve values in input order and reject as soon as one task fails.
Test focus: fail-fast, empty input, non-promise values, ordering.
Requirement: choose between all, allSettled, race, and any for product behavior.
Test focus: partial failure, first result, first fulfillment, retries.
Requirement: predict output when sync code, promises, timers, and await mix.
Test focus: microtasks before timers, await continuation, rendering timing.
Requirement: explain retained lexical scope and implement small stateful functions.
Test focus: loop capture, stale callbacks, retained memory, factories.
Requirement: reason about call-site binding and implement native-like helpers.
Test focus: constructor calls, prototypes, arrow functions, partial args.
Requirement: implement or explain array transformations without mutating source data.
Test focus: sparse arrays, callback args, initial value, return shape.
Requirement: reshape nested or grouped data into the form a UI can render.
Test focus: empty inputs, key coercion, depth, recursion boundaries.
Requirement: compare or copy nested values while naming practical limits.
Test focus: arrays, dates, cycles, functions, object identity.
Requirement: subscribe, emit, unsubscribe, and preserve listener ordering.
Test focus: once handlers, removal during emit, duplicate listeners.
Requirement: handle dynamic children through one parent listener.
Test focus: closest target, containment, bubbling, cleanup.
Treat this as a checklist, not a memorization list. For each prompt, state the requirement, name edge cases, implement a baseline, and verify at least one failing path.
These examples are intentionally compact. The goal is to show the interview shape: clarify the contract, model state, handle edge cases, and link the implementation to a direct drill.
Practice route: /javascript/coding/js-debounce.
cancel or flush?this, arguments, and return value?this is preserved.let timerId: ReturnType<typeof setTimeout> | null = null;
return function debounced(this: unknown, ...args: unknown[]) {
const context = this;
if (timerId) clearTimeout(timerId);
timerId = setTimeout(() => {
timerId = null;
fn.apply(context, args);
}, wait);
};Practice route: /javascript/coding/js-promise-all.
Resolve an array of values in the same order as input, regardless of completion order.
Reject immediately when any input rejects; do not wait for slower tasks to settle.
Empty input resolves to []. Non-promise values are wrapped with Promise.resolve.
Track results[index] and a settled count. Resolve when count equals input length.
const results = new Array(inputs.length);
let settled = 0;
inputs.forEach((input, index) => {
Promise.resolve(input).then((value) => {
results[index] = value;
settled += 1;
if (settled === inputs.length) resolve(results);
}, reject);
});Concept routes: /javascript/trivia/js-event-loop and /javascript/trivia/js-microtasks-vs-macrotasks.
| Queue | Interview wording | Common miss |
|---|---|---|
| Sync stack | Run top-level code first. | Jumping to timers before finishing normal function calls. |
| Microtasks | Promise callbacks and await continuations run before timers. | Treating await as if it blocks the whole thread. |
| Macrotasks | Timers run in a later task after microtasks drain. | Assuming setTimeout(..., 0) means immediate execution. |
console.log('sync');
setTimeout(() => console.log('timer'), 0);
Promise.resolve().then(() => console.log('microtask'));
(async () => {
await null;
console.log('await continuation');
})();
// Output: sync, microtask, await continuation, timerStay in the JavaScript function lane when the round is utility-heavy, then move into UI or framework surfaces when the interviewer expects a visible component.
Common prompts include debounce, throttle, Promise.all, event loop tracing, closures, this binding, array helpers, deep clone/equal, EventEmitter, and DOM event delegation.
Start with one direct drill, state the input/output contract, name edge cases, implement a baseline, then test cancellation, ordering, context, empty input, and repeated calls.
Prioritize Promise.all, Promise combinators, sleep, concurrency-limited map, takeLatest, and stale-response handling because they expose ordering, rejection, and async race behavior.
Trace sync code first, then microtasks, then macrotasks. Write the expected output before running, and explain how await schedules the continuation as promise work.
Yes. The JavaScript interview questions and answers hub is for short-answer concept review. This guide is a practice map that connects high-frequency patterns to direct coding and concept drills.