Skip to main content

JavaScript Interview Mastery

Strong interview answers separate language semantics, host behavior and engine implementation. State assumptions, predict behavior, then show how you would verify it.

Fifteen mock rounds​

  1. fundamentals, declarations and control flow;
  2. types, coercion and equality;
  3. functions, scope and closures;
  4. this, call sites and API design;
  5. objects, descriptors and prototypes;
  6. classes, composition and domain modeling;
  7. arrays, Maps/Sets and complexity;
  8. Promises, async/await and cancellation;
  9. event loop and output prediction;
  10. modules, packages and compatibility;
  11. DOM, accessibility and browser APIs;
  12. testing, debugging and production incidents;
  13. performance, memory and engine reasoning;
  14. security and code review;
  15. system-design-style JavaScript architecture.

Answer framework​

Definition → mental model → minimal example → edge case
→ production trade-off → test/debug method

For output questions, trace synchronous execution, binding resolution, conversions, Promise Jobs/microtasks and host tasks in order. Do not guess from remembered snippets.

Representative deep questions​

Why does a closure retain state? Explain lexical environments, reachability and mutable bindings; distinguish retention from a leak.

What does this equal? Start from the call expression, function kind and strictness. Avoid “the object where the function lives.”

Why can Promise.all be dangerous? It can create unbounded concurrency, rejects early without cancelling peer work, and needs explicit partial-failure policy.

When would you use Map instead of Object? Discuss dynamic/non-string keys, size, iteration, prototype concerns and record semantics.

How do you investigate a slow page? Start with field impact, record a trace, identify network/main-thread/rendering bottlenecks, form a hypothesis and add a regression metric.

How do you prevent XSS? Trace untrusted data to context-specific sinks, prefer safe DOM APIs, sanitize necessary rich HTML, use CSP/Trusted Types as defense in depth and validate URLs/messages.

Coding rounds​

Practice transformations, debounce/throttle with cancellation, concurrency limiters, event emitters, LRU caches, deep comparison with defined supported types, DOM autocomplete, async pagination and graph traversal. Always clarify constraints and expose complexity.

Senior code review​

Look for hidden mutation, incomplete validation, lost Promise ownership, stale async writes, listener cleanup, unsafe sinks, unbounded queues/caches, incorrect equality, module cycles and missing observability.

Staff architecture discussion​

Frame decisions around boundaries, reliability, deployability, compatibility, security and organizational cost. Offer alternatives and migration paths. “Use microservices” or “use a framework” is not a design answer.

Behavioral technical stories​

Prepare evidence-driven stories for a production incident, performance improvement, architectural disagreement, security/reliability improvement and mentoring decision. State situation, constraints, actions, measurable outcome and what changed in your practice.

Use the existing 384-question bank and fifteen detailed mock rounds after completing the focused pages and 300-problem logic track.