Front End Interview Guidebook/Preparation by Question Type/Coding Questions/JavaScript Questions

Front End Interview JavaScript Questions — How to Prepare

Guide to preparing for JavaScript questions in front end / web developer interviews — Concepts to know, interview rubrics, and 70+ important practice questions.

The difference between coding 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 or have basic 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:

  1. Implement classes or methods in the JavaScript standard library.
  2. Implement a utility function/class commonly found in libraries/frameworks.


JavaScript Standard Library Classes/methods

It may seem redundant that candidates have to implement them when they are already part of the language. However, browsers inconsistencies used to be a thing 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 functionality also shows good understanding of front end fundamentals.

Utility Function/class from Libraries/Frameworks

What to do during JavaScript Coding Interviews

JavaScript coding interviews share a lot of similarities with non-front end coding interviews. In general, you should:

  1. 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 dependencies beforehand.
  2. Make your self introduction under a minute. Unless requested, do not take longer than this otherwise you might not have enough time to code.
  3. 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.
  4. 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.
  5. Code out your solution and explain your code to your interviewer while you are coding.
  6. After coding, read through your code once and try to spot basic errors like typos, using variables before initializing them, using APIs incorrectly, etc.
  7. 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.
  8. Optional: Explain the time/space complexity if the code involved algorithmic optimizations.
  9. Explain any tradeoffs you made, cases you explicitly didn't handle, and how you would improve the code if you had more time.
  10. 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

  1. 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.
  2. 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

CategoryImportant Topics
Data StructuresArrays, Maps, Stacks, Trees, Sets
AlgorithmsBinary Search, Breadth-first Search, Depth-first Search, Recursion
JavaScript LanguageData 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()/, Promise, Handling variadic arguments
DOMDOM traversal, DOM creation, DOM manipulation, Accessing element/node properties, Event delegation
Runtime APIsTimer (setTimeout, setInterval)

JavaScript Coding Interview Rubrics

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 on how interviewers evaluate candidates 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.


  • 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.
  • 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.
  • 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.
  • Complexity arising due to recursion:
    • 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 is a good signal.
    • Nested deep data structures can have recursive references to itself, which makes certain operations like serialization much trickier. Ask the interviewer if you have to handle such cases. Usually you won't have to handle it but raising this issue is a good signal.

Practice Questions

GreatFrontEnd has a comprehensive list of JavaScript coding questions that you can practice. There are also automated tests 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 some stuff, but this trains you to think ahead and consider what are the possible things you have to take note of when working on the solution. Better to find out during practice than during actual interviews.