JavaScript Coding Interviews
Question types to expect, important concepts to know and top practice questions to do
The difference between JavaScript coding questions vs algorithmic coding questions is that the former is usually specific to the front end domain and it makes the most sense to use JavaScript (or TypeScript) to complete them. You will also probably need to make use of browser/JavaScript-specific APIs and/or utilize HTML/CSS/JavaScript knowledge.
These JavaScript coding questions tend to be practical in nature and can come in one or more of the following categories:
- Implement standard built-in classes or methods in the JavaScript language
- Implement a utility function/class commonly found in popular libraries
Start here: top practice questions
If you'd like to begin practising straight away, the questions below are among the most valuable to work through — they appear most frequently in real interviews and cover the concepts that interviewers examine most thoroughly:
- Debounce
- Throttle
- Array.prototype.filter
- Promise.all
- Curry
- Flatten
- getElementsByTagName
- Deep Clone
- Data Selection
Looking to practice more JavaScript interview questions? This guide covers how to approach JavaScript interviews. If you're ready to start practicing, head straight to our JavaScript practice questions — 160+ problems with solutions, organised by topic.
Time-budgeted study plans
Realistic preparation plans depending on how much time you have before your interviews. Each plan below also has a dedicated, fully curated version on GreatFrontEnd with a recommended question sequence — the 1-week study plan, 1-month study plan, and 3-month study plan.
1 week (short timeline, assumes existing frontend experience)
Prioritise pattern recognition over deep mastery. For a fully guided day-by-day version, see the 1-week study plan.
- Day 1–2: Debounce and Throttle. Understand
leading/trailingedges and howthisis preserved. - Day 3: Promise.all and Promise.any. Make sure you are confident with the resolve and reject semantics.
- Day 4: Curry and Flatten — recursion patterns.
- Day 5: Deep Clone — circular refs, Date, Map, Set handling.
- Day 6: EventEmitter — OOP + chaining.
- Day 7: Timed retry of your weakest problem from above (35 minutes, without referring to the solution). Then review the solution carefully.
Skip array method polyfills beyond filter/map, and more obscure utilities.
1 month (standard preparation timeline)
A week-by-week progression from fundamentals through to polish. For a fully structured version, see the 1-month study plan.
- Week 1 — foundations: Closures,
this, prototypes,Promiseinternals. Work throughArray.prototype.map,filter, andreducepolyfills. - Week 2 — async: Debounce, Throttle, Promise.all, Promise.allSettled, promise retry with backoff.
- Week 3 — data structures and utilities: Curry, Flatten, Deep Clone, classnames,
EventEmitter. - Week 4 — DOM and polish:
getElementsByClassName,getElementsByTagName, event delegation. Complete 3 timed rehearsals (35 minutes each, without referring to solutions, explaining your approach out loud).
3 months (comprehensive preparation, for juniors or career switchers)
Build depth alongside practice. For a fully structured version, see the 3-month study plan.
- Month 1: JavaScript language fundamentals — closures,
this, prototypes, scopes,Promise, event loop — plus the Quiz section. PracticeArraymethod polyfills as you go. - Month 2: Full pass through the JavaScript coding questions — aim for 2–3 problems a day. Attempt each without looking first, then compare against the solution.
- Month 3: Revisit weak areas. Complete six or more timed mock interviews (with a peer or through self-rehearsal) and practise explaining tradeoffs out loud. Start reading real library source code such as lodash's
debounce— recognising production patterns is a strong senior signal.
JavaScript interview study checklist
A topic-by-topic checklist to guide your preparation, with realistic time estimates so you can plan your study sessions. The first table covers the core topics to study first; the second covers additional topics that commonly appear in senior and FAANG rounds.
Core topics
| Topic | Realistic time to master |
|---|---|
| Closures + lexical scope | 2–3 hours |
this binding rules (+ call/apply/bind) | 2 hours |
Promise internals + async/await | 3–4 hours |
Array.prototype.map/filter/reduce | 2 hours |
| Debounce and Throttle | 2 hours |
Promise.all (+ allSettled, any, race) | 2 hours |
| Deep clone + circular references | 2 hours |
| Event delegation + DOM traversal | 2 hours |
Additional topics for senior and FAANG rounds
| Topic | Realistic time to master |
|---|---|
| Curry (fixed + variadic arity) | 1–2 hours |
| Flatten (recursive, iterative, generator) | 1–2 hours |
EventEmitter / pub-sub | 2 hours |
classnames/clsx implementation | 1 hour |
| Promise retry with exponential backoff | 1–2 hours |
| Memoization with custom cache keys | 2 hours |
| Event loop ordering (micro vs macrotasks) | 2–3 hours |
| JSON stringify/parse edge cases | 1 hour |
Common pitfalls to avoid
Common mistakes that can weaken your performance in JavaScript coding interviews, grouped by the question type where they tend to appear:
Debounce / Throttle
- Using an arrow function for the timer callback and losing
this— suggests unfamiliarity with the difference between regular and arrow-function binding. - Not clearing the previous timeout on subsequent calls, which actually implements a throttle rather than a debounce.
- Forgetting to forward arguments using rest and spread.
- Not asking clarifying questions about
leadingortrailingedge behaviour.
Promise.all and friends
- Pushing into a results array as each promise resolves, which makes the output order non-deterministic rather than matching the input order.
- Not handling empty input correctly — the specification requires resolving with
[]rather than leaving the promise pending indefinitely. - Confusing
Promise.all(fail-fast) withPromise.allSettled(never rejects) when explaining the behaviour. - Not using
Promise.resolve(value)to normalise non-promise inputs.
Deep clone
- Using
JSON.parse(JSON.stringify(obj))without acknowledging the limitations:Dateis converted to a string,undefinedis dropped,NaNbecomesnull, and it throws on circular references. - Not handling circular references with a
WeakMapvisited set. - Forgetting to preserve the prototype chain and class identity.
- Cloning
MaporSetthrough shallow iteration while overlooking that the values themselves may also beMaporSetinstances that require recursive cloning.
Closures and this
- Being surprised by the classic
3, 3, 3output when usingvarinside aforloop withsetTimeout— candidates are generally expected to recognise this closure pitfall immediately and explain the fix. - Using
thisinside a callback passed tomaporforEachwithout noting that it will not refer to the outer context. - Claiming classes are not hoisted — they are hoisted, but remain in the temporal dead zone until the declaration is evaluated.
DOM
- Calling
document.querySelectorAllinside a loop rather than caching the NodeList — suggests unfamiliarity with DOM performance considerations. - Re-attaching event listeners after mutating
innerHTMLwithout explaining why the previous listeners were lost. - Overlooking that live
HTMLCollectionobjects (such as those returned bygetElementsByTagName) update as the DOM changes, while staticNodeListobjects do not — a distinction that affects iteration correctness.
Examples of JavaScript coding questions
JavaScript standard built-in classes/methods
It may seem redundant to implement standard classes/methods when they are already part of the language. However, browser inconsistencies used to be a rampant problem and some language APIs are not found in older browsers. Hence developers had to resort to polyfilling, the act of providing modern functionality on older browsers that do not natively support it by implementing these APIs in downloaded JavaScript. Being able to implement these native functions also shows good understanding of front end fundamentals.
Arraymethods:Array.prototype.map,Array.prototype.reduce,Array.prototype.filterPromiseand otherPromise-related functions:Promise.all,Promise.any- DOM methods:
document.getElementsByTagName,document.getElementsByClassName
There's more to these functions than meets the eye. Let's take the innocent Array.prototype.map for example. Are you aware that:
- It passes 4 arguments to the callback, including the
indexandthis? - It keeps the "holes" in sparse arrays, aka
[1, 2, , 4].map(val => val * val) === [1, 4, , 16] - The range of elements processed by
mapis set before the first call to callbackfn. Elements which are appended to the array after the call tomapbegins will not be visited by callbackfn. If existing elements of the array are changed, their value as passed to callbackfn will be the value at the timemapvisits them; elements that are deleted after the call tomapbegins and before being visited are not visited. Source:Array.prototype.mapECMAScript specification
Your implementation doesn't have to handle all of these cases, especially the array mutation one. However, it's a positive signal if you mentioned these cases. The closer your implementation is to the specification, the more senior/experienced you will appear to be.
Mentioning sparse arrays, callback arguments like index and thisArg, or spec-defined behaviors — even if you skip handling them — signals depth of understanding. Interviewers reward candidates who know what is out there, not just candidates who cover the happy path.
Utility function/class from popular libraries
These functions/classes are commonly needed when building software with JavaScript but aren't in the standard language (for now).
- Lodash/Underscore functions:
debounce,throttle,flatten,curry,cloneDeep - jQuery methods:
jQuery.css,jQuery.toggleClass - Popular libraries:
classnamestest/expectfunctions from testing frameworks like Jest/Mocha/VitestEmitter(which exists as part of Node.js and many third party libraries)- Immutable.js
- Backbone.js
If you take a look at the source code of these libraries, you might find some of the implementation to be quite complex. This is because there are lots of obscure real world use cases that the library has to support. Similar to the standard functions, you're not expected to handle all of these edge cases within an interview setting but you get points for calling them out.
What to do during JavaScript coding interviews
JavaScript coding interviews share a lot of similarities with algorithmic coding interviews. In general, you should:
- Find out what platform you are coding on and familiarize yourself with the coding environment:
- The supported editor shortcuts
- Whether you can execute code
- Whether you can install 3rd party dependencies
- Make your self introduction under a minute. Unless requested, do not take longer than this otherwise you might not have enough time to code.
- Ask clarifying questions upon receiving the question. Clarify the following:
- Can you use newer JavaScript syntax (ES2016 and beyond)?
- Whether the code is meant to run in the browser or on the server (e.g. Node.js)
- Browser support, as this will affect the browser APIs you can use
Runtime (browser vs Node.js), supported syntax, and browser compatibility directly affect which APIs are on the table. Locking these down early prevents rewriting your solution halfway when the interviewer says "this needs to work in IE11" or "no ES2020 features."
- Propose a solution to your interviewer. Unlike coding interviews, the focus of JavaScript coding interviews is usually not on complex data structures and algorithms. It's possible and likely you can jump straight to the optimal solution with the best choice of data structures and algorithms.
- Code out your solution and explain your code to your interviewer while you are coding.
- After coding, read through your code once and try to spot basic errors like typos, using variables before initializing them, using APIs incorrectly, etc.
- Outline some basic test cases and some edge cases. Test your code with these cases and determine if your code passes them. If it fails, debug the issue(s) and fix them.
- Optional: Explain the time/space complexity if the code involved algorithmic optimizations and smart choice of data structures.
- Explain any tradeoffs you made, cases you explicitly didn't handle, and how you would improve the code if you had more time.
- The interview might not end here, the interviewer might have follow-up questions for you on this question or give you another question. Be prepared for them.
How to prepare for JavaScript coding interviews
- Be familiar with HTML, CSS, JavaScript, and DOM concepts by referring to the "Important Concepts" below. The Quiz section can also be a good start since you might be asked on these concepts in the form of quiz questions during coding.
- Pick a study plan and practice the JavaScript coding questions recommended for the selected study plan. It's also alright to study for a certain topic as you are doing the questions.
Important concepts
| Category | Important topics |
|---|---|
| Data structures | Arrays, Maps, Stacks, Trees, Sets |
| Algorithms | Binary search, Breadth-first search, Depth-first search, Recursion |
| JavaScript language | Data types (checking for types, type coercion), Scope, Closures, Callbacks, How this keyword works, Object-oriented programming in JavaScript (prototypes, classes, methods), Arrow functions vs normal functions, Invoking functions via Function.prototype.apply()/Function.prototype.call(), Promise, Handling variadic arguments |
| DOM | DOM traversal, DOM creation, DOM manipulation, Accessing element/node properties, Event delegation |
| Runtime APIs | Timer (setTimeout(), setInterval()) |
Evaluation axes
JavaScript coding interviews are similar to algorithmic coding interviews and the way to go about the interviews should be similar. Naturally, there will be some overlaps with algorithmic coding interviews regarding how candidates are evaluated during JavaScript coding interviews.
- Problem solving: Use a systematic and logical approach to understanding and addressing a problem. Break down the problem into smaller independent problems. Evaluate different approaches and their tradeoffs
- Software engineering foundation: Familiarity with data structures, algorithms, runtime complexity analysis, use of design patterns, design solution with clean abstractions
- Domain expertise: Understanding of the front end domain and the relevant languages: Browser (DOM and DOM APIs), HTML, CSS, JavaScript, Performance
- Communication: Ask questions to clarify details and clearly explaining one's approach and considerations
- Verification: Identify various scenarios to test the code against, including edge cases. Be able to diagnose and fix any issues that arise
Useful tips
- Wishful thinking: JavaScript's standard library doesn't have some useful data structures and algorithms like queue, heap, binary search, which can make your life easier during JavaScript coding interviews. However, you can ask the interviewer if you can pretend such a data structure/algorithm exists and use it directly in your solution without implementing it.
- Pure functions: Aim to write pure functions which have the benefit of reusability and modularity, aka functions which don't rely on state outside of the function and doesn't cause side effects.
- Choose data structures wisely. Pay attention to your choice of data structures and be aware of the time complexities of the code. Be familiar with the time/space complexities of the basic JavaScript Array, Object, Set, Map operations should you want to use them in your solution. Some of these time/space complexities differ across languages. Don't write code that runs in O(n2) if it can accomplished in O(n) runtime with the use of hash maps.
thismatters: If a function accepts a callback function as a parameter, consider how thethisvariable should behave. For many built-in functions,thisis provided as one of the arguments the callback function is invoked with.- Mutations within callback functions. Beware of callback functions mutating the data structure it is operating on. You probably do not need to handle this case during interviews but you should explicitly mention such cases if it's relevant.
- Recursion edge cases:
- Clarifying input size: If you have identified that solving the question requires recursion, ask about the input size and how to handle the case of recursion stack overflow. Usually you won't have to handle it but raising this issue demonstrates thoughtfulness.
- Cyclic structures: Nested deep data structures can have recursive references to itself, which makes certain operations like serialization and traversal more tricky. Ask the interviewer if you have to handle such cases. Usually you won't have to handle it but raising this issue demonstrates thoughtfulness.
GreatFrontEnd has a comprehensive list of JavaScript coding questions that you can practice. There are also automated test cases you can run your code against to verify the correctness and solutions written by ex-FAANG Senior Engineers.
Note that we are intentionally vague in some of the questions and don't present the full requirements upfront in the question description. However, we'll cover as much ground as possible in the solution. It may be frustrating while reading the solutions to see that you've missed out on some things, but this trains you to think ahead and consider what are the possible areas you have to take note of when working on the solution. Better to find out during practice than during actual interviews.
Prefer GitHub for learning? You can find 190+ JavaScript coding interview questions with solutions in our GreatFrontEnd GitHub repo. Clone it, practice offline, or contribute while continuing here for structured guidance.