How the call stack, microtask queue, and macrotask queue decide execution order — with the output-prediction questions interviewers love.
67 interview questions and coding challenges · 9 categories · Covers ES2025
JavaScript Interview Questions & Coding Challenges
Practice 67 JavaScript interview questions and coding problems with worked solutions, edge cases, and interviewer follow-ups. Start with language fundamentals, then build up to promise concurrency, DOM patterns, and machine-coding exercises.
Quick answer
These JavaScript interview questions and coding challenges cover recurring frontend and full-stack problems: closures, the event loop, debounce and throttle, Promise combinators, deep cloning, polyfills, DOM patterns, and machine-coding tasks. Each challenge links to a worked solution with edge cases and interviewer follow-ups.
Suggested learning path
Categories are ordered as a ramp — each stage leans on the ones before it. Work top to bottom, or jump to wherever you left off.
- JavaScript FundamentalsContinue hereHow the language actually works — everything else builds on these four.0/4
- Modern JavaScript (ES2023–ES2025)The 2024–2025 built-ins that replaced utilities you used to hand-roll.0/4
- Debounce, Throttle & TimersFirst implementations: closures and timers driving real UI patterns.0/5
- Promises & Async PatternsThe biggest category — combinators first, then the patterns they compose into.0/15
- Functional Programming PatternsClosure fluency: curry, compose, memoize.0/7
- Objects, Arrays & CloningReferences, recursion, and equality — the data-structure drills.0/6
- Polyfills & Language InternalsRebuild the standard library to prove you know the spec.0/13
- DOM, Events & UI PatternsBridge language knowledge into framework internals.0/8
- Machine Coding PatternsCompose everything into small working systems, under interview time.0/5
JavaScript Fundamentals
The concepts every other question builds on. Interviewers probe these to see whether you understand how the language actually works, not just its syntax.
- intermediateVery common
What a closure really is, why loops with var trip people up, and how closures power memoization, once(), and module patterns.
beginnerVery commonThe four binding rules, arrow-function behavior, and the lost-this bugs that call, apply, and bind exist to fix.
intermediateVery commonThe prototype chain, __proto__ vs prototype, and what class syntax actually does under the hood.
intermediateCommon
Modern JavaScript (ES2023–ES2025)
Recent language features that are now fair game in interviews — and often the sanctioned replacement for utilities you used to hand-roll.
Object.groupBy, Promise.withResolvers, Set methods, iterator helpers, and the other additions worth knowing in interviews.
intermediateCommonThe ES2024 way to create a promise you settle from outside — and how to implement the deferred pattern it replaces.
intermediateCommonmap, filter, take, and drop directly on iterators (ES2025): lazy evaluation without loading everything into an array.
advancedRareImplement groupBy from scratch, then meet the ES2024 built-ins — including the null-prototype result and Map.groupBy for object keys.
intermediateCommon
Debounce, Throttle & Timers
Rate-limiting user input and understanding JavaScript timers — among the most frequently asked practical frontend questions.
Implement debounce from scratch, with leading/trailing options and the classic search-input use case.
beginnerVery commonImplement throttle and know exactly when to reach for it instead of debounce (scroll, resize, mousemove).
beginnerVery commonRebuild setTimeout on top of requestAnimationFrame to show you understand timer scheduling and drift.
advancedRareImplement setInterval with setTimeout recursion — and fix the drift problems of the native version.
intermediateCommonTrack and clear every active timeout and interval — a utility question about monkey-patching globals safely.
intermediateRare
Promises & Async Patterns
The largest interview category: reimplement the Promise combinators, then compose them into retry, batching, and concurrency-control patterns used in real applications.
Implement a spec-faithful Promise with then chaining, state transitions, and async resolution.
advancedVery commonImplement Promise.all: aggregate results in order, fail fast on the first rejection.
intermediateVery commonImplement allSettled: wait for every promise and report per-promise status objects.
intermediateCommonImplement Promise.any with AggregateError semantics: first success wins, all failures reject.
intermediateCommonImplement Promise.race and use it for the timeout pattern every senior interview touches.
beginnerCommonImplement finally correctly: pass values through, and don't swallow rejections.
intermediateCommonRun N async tasks with at most K in flight — the production-style p-limit pattern, including ordering and failure trade-offs.
advancedVery commonCancel fetch requests, add timeouts with AbortSignal.timeout, and write abortable async utilities.
intermediateCommonRetry a failing async operation N times with backoff — a small function with big production implications.
intermediateCommonProcess a large list of async tasks in fixed-size sequential batches to protect downstream services.
intermediateCommonRun async tasks one after another and understand why reduce-with-promises works.
beginnerCommonFire all tasks at once and gather results — plus what parallel really means on a single thread.
beginnerCommonFirst settled task wins: build the primitive behind timeouts and fastest-source fetching.
beginnerRareConvert error-first callback APIs into promise-returning functions, like Node's util.promisify.
intermediateCommonCache in-flight and resolved requests to deduplicate API calls — with cache invalidation trade-offs.
intermediateCommon
Functional Programming Patterns
Currying, composition, and the lodash utilities interviewers ask you to rebuild to test closure fluency.
Transform f(a, b, c) into f(a)(b)(c): the classic closure exercise, with arity handling.
intermediateVery commonThe harder follow-up: support _ placeholders so arguments can arrive in any order.
advancedRareCompose functions left-to-right into a pipeline — the one-liner with a lot of interview depth.
intermediateCommonPre-fill leading arguments of a function — partial application, and how it differs from currying.
intermediateRareGuarantee a function runs exactly once and returns its cached result forever after.
beginnerCommonCache function results by argument key — and discuss cache-key strategy and memory trade-offs.
intermediateVery commonA single-slot memoizer that remembers only the previous call — the pattern behind React's useMemo.
intermediateCommon
Objects, Arrays & Cloning
Deep equality, deep cloning, and array manipulation — questions that expose how well you understand references, recursion, and edge cases.
When to use the built-in structuredClone, where it fails (functions, prototypes), and how it compares to JSON round-tripping.
intermediateCommonRecursively clone nested objects and arrays, handling cycles with a WeakMap.
advancedVery commonStructural equality for nested data: type checks, key comparison, and recursion done right.
intermediateCommonFlatten arbitrarily nested arrays recursively and iteratively — then compare with Array.prototype.flat.
beginnerVery commonTurn nested objects into dot-path keys ({ 'a.b.c': 1 }) and back — the transform behind form libraries and analytics events.
intermediateVery commonUse a Proxy to support arr[-1] like Python — a practical introduction to Proxy traps.
advancedRare
Polyfills & Language Internals
Rebuild the standard library. These questions verify you know what the built-ins actually do, including the edge cases.
Implement call from scratch: temporary method assignment and why Symbol keys avoid collisions.
intermediateCommonSame trick as call but with an arguments array — plus the subtle differences that interviewers probe.
intermediateCommonImplement bind including partial application and the new-operator edge case most candidates miss.
advancedVery commonImplement myNew(Constructor, ...args): prototype linking, this binding, and the return-object override rule.
intermediateCommonWalk the prototype chain by hand, then meet Symbol.hasInstance — and learn where instanceof lies to you.
intermediateCommonCopy enumerable own properties across sources, with getter evaluation and null-target errors.
intermediateRareThe equality that fixes === for NaN and -0: tiny implementation, classic trivia follow-ups.
beginnerRareReimplement typeof with Object.prototype.toString and learn why typeof null === 'object'.
beginnerRareSerialize values by hand: undefined, functions, cycles, and all the special cases JSON defines.
advancedCommonWrite a small recursive-descent parser — the deepest polyfill question in the set.
advancedRareImplement reduce including the no-initial-value case and empty-array TypeError.
intermediateCommonStrip whitespace without regex catastrophes — and enumerate what counts as whitespace.
beginnerRareSplit source text into tokens — a warm-up for parsing questions like JSON.parse.
intermediateRare
DOM, Events & UI Patterns
Event emitters, history, virtual DOM, and state management — the frontend-system questions that bridge JavaScript knowledge and framework internals.
Implement on, off, once, and emit — the pub/sub pattern behind Node streams and countless libraries.
intermediateVery commonImplement delegate(root, selector, handler) with closest() — one listener for a thousand rows, and why frameworks did exactly this.
intermediateVery commonModel back/forward/push navigation with an index and a stack — the core of every router.
intermediateCommonTurn real DOM into a plain-object tree — the first half of understanding how React represents UI.
advancedRareRebuild real DOM from the virtual tree, completing the render pipeline.
advancedRareDiff two virtual trees and apply minimal DOM mutations — the reconciliation step that makes the virtual DOM worth having.
advancedCommonRebuild the classnames utility: strings, arrays, objects, and nested combinations.
beginnerCommonA mini Redux store with Immer-style draft mutations — reducers, subscriptions, and immutability.
advancedRare
Machine Coding Patterns
Small systems, not single functions: the 30–45 minute build-a-working-thing questions used to test composition, state, and browser API fluency.
O(1) get/put with least-recently-used eviction — the Map insertion-order trick, and the linked-list version interviewers ask about.
advancedVery commonDebounce, cancellation, and stale-response guards composed into a search box that never shows the wrong results.
advancedVery commonIntersectionObserver, in-flight guards, end-of-data states, and the sentinel pattern — the pagination question every feed team asks.
advancedVery commonA dependency-free rating component: event delegation, hover preview vs committed state, keyboard support, and the ARIA pattern.
intermediateCommonA concurrency-limited scheduler with priorities and cancellation — the pool question upgraded to the API-design round.
advancedCommon
How these challenges are selected
The catalog prioritizes problems that reveal JavaScript behavior, implementation trade-offs, and edge-case reasoning—not syntax trivia. Difficulty reflects the reasoning and implementation depth required; interview-frequency labels are editorial estimates and should be used as a practice priority, not as an employer-specific guarantee.
JavaScript interview question and coding challenge FAQs
- Which JavaScript interview questions and coding challenges should I practice?
- Start with closures, the event loop, this-binding, debounce and throttle, Promise.all-style combinators, deep clone, currying, bind, and event emitters. For senior frontend interviews, add promise concurrency, cancellation, LRU caches, typeahead, infinite scroll, and small DOM or machine-coding exercises.
- What JavaScript topics are asked most in interviews?
- Closures, the event loop, promises, and this-binding dominate conceptual rounds, while debounce/throttle, Promise.all-style combinators, deep clone, and Function.prototype.bind are the most common implementation questions. Senior loops increasingly add concurrency control (promise pools) and cancellation with AbortController.
- Should I memorize polyfill implementations?
- No — interviewers check whether you understand the behavior you're recreating: edge cases, spec semantics, and why the built-in works the way it does. Practice deriving each implementation from the behavior you can describe, not reciting code. If you can explain call vs apply vs bind and the no-initial-value case of reduce, the code follows.
- Are ES2024 and ES2025 features fair game in interviews?
- Yes, increasingly. Object.groupBy, Promise.withResolvers, Set operations like intersection and union, and iterator helpers now appear in senior frontend interviews — often as a follow-up: 'you implemented it; does the language provide it now?' Knowing the modern built-in and its limits is a strong senior signal.
- How should I practice these questions?
- Work category by category: read the problem, implement it yourself in an editor before reading the solution, then compare against the edge cases covered in the article. Re-implement from memory two days later. Use the completion tracker on this page to keep your place — most candidates need two passes through the catalog over three to four weeks.
- Do these questions cover React or only plain JavaScript?
- The catalog is deliberately framework-free — that's what JavaScript rounds test. But many questions are the internals of framework features: memoizeLast is React's useMemo, the event emitter is Node streams, and the virtual DOM pair shows how React represents UI. Mastering them makes framework questions easier.
Keep going
JavaScript questions are one round. Compare the language and runtime trade-offs with the Java interview knowledge hub, connect the language fundamentals to the Angular interview knowledge hub, then pair them with system design deep dives and the Distributed Systems field manual for senior loops, or generate a personalized prep roadmap.