PlacementPrep IndiaPowered by AcePrep
Frontend & WebBeginner • Intermediate • Advanced

JavaScript Mock Interview

JavaScript internals — especially the event loop, microtask vs macrotask priority, closures, and debouncing — are favorite elimination questions in frontend and Node.js interviews across Indian tech companies.

Frequently Asked By:AmazonFlipkartAtlassianUberSwiggyPaytmTCS Digital

3-Level JavaScript Placement Syllabus

Beginner Tier
  • var vs let vs const & TDZ
  • Hoisting & Lexical Scope
  • == vs === & Type Coercion
  • Array Methods (map, filter, reduce)
Intermediate Tier
  • Closures & Memory Leaks
  • Event Loop: Call Stack, Microtasks & Macrotasks
  • Promises, async/await & Promise.allSettled
  • `this` Binding, call/apply/bind
Advanced Tier
  • Prototypal Inheritance & Object.create
  • Debounce vs Throttle Implementation
  • Garbage Collection & WeakMap
  • Event Delegation & Bubbling
INTERACTIVE BROWSER DEMO • ZERO INSTALL

Try a Spoken or Typed Mock Interview Right Now

JavaScriptIntermediateQ1 / 3

“Explain how the JavaScript Event Loop prioritizes synchronous code, Promise callbacks, and `setTimeout(..., 0)`.”

Focus log (info only): 0 blurs • 0 pastes

High-Frequency Spoken JavaScript Questions & Rubric Criteria

Study how interviewers probe beyond definitions with adaptive follow-ups and what AcePrep's 0–10 scoring rubric checks in your spoken explanation.

QUESTION 01Intermediate

Explain how the JavaScript Event Loop prioritizes synchronous code, Promise callbacks, and `setTimeout(..., 0)`.

Adaptive Follow-Up Probe

What happens to UI rendering if a recursive Promise microtask chain keeps scheduling new microtasks endlessly?

What the Rubric Checks

  • • Traces Call Stack -> Microtask Queue (Promises, queueMicrotask) -> Macrotask Queue (setTimeout, I/O)
  • • Explains that the microtask queue drains completely before the next paint/macrotask
  • • Identifies UI starvation risk

High-Scoring Answer Blueprint

Synchronous code runs on the call stack to completion first. Next, the event loop drains the entire microtask queue (Promise `.then`/`.catch`, `queueMicrotask`) before picking a single macrotask (`setTimeout`, DOM events) or letting the browser repaint. Infinite microtasks therefore starve rendering and freeze the tab.

QUESTION 02Intermediate

What is a JavaScript closure, give a practical engineering use case, and explain how closures can accidentally cause memory leaks.

Adaptive Follow-Up Probe

Compare `debounce` and `throttle` — how do both rely on closures, and where would you use each in an interview web app?

What the Rubric Checks

  • • Defines lexical environment persistence after outer function returns
  • • Gives real example (private state, memoization, debounce/throttle)
  • • Explains retained references to detached DOM nodes or large objects

High-Scoring Answer Blueprint

A closure is a function bundled with references to its surrounding lexical scope even after the outer function finishes. Practical uses include debouncing search inputs, throttling scroll handlers, and encapsulating private state. Memory leaks happen when long-lived closures keep references to detached DOM nodes or large buffers.

QUESTION 03Beginner

Compare `Promise.all`, `Promise.allSettled`, and `Promise.race` — and choose the right one when firing parallel API calls with a fallback.

Adaptive Follow-Up Probe

Does `Promise.race` cancel the losing network requests automatically? How would you actually cancel them?

What the Rubric Checks

  • • Accurately contrasts fail-fast vs wait-all vs first-settled semantics
  • • Mentions `AbortController` to cancel in-flight fetch requests
  • • Gives concrete engineering scenario

High-Scoring Answer Blueprint

`Promise.all` resolves when all succeed and rejects immediately on the first error. `Promise.allSettled` waits for every promise and returns each status/value/reason — great for partial fallbacks. `Promise.race` settles with whichever finishes first, useful for timeouts, paired with `AbortController` to actually abort losing fetches.

JavaScript Interview FAQs

Are Node.js backend JS questions covered too?

Yes! Event loop mechanics, async error handling, streams, and non-blocking concurrency are relevant to both browser JavaScript and Node.js Express interviews.

Continue Practicing Related Tracks