Common JavaScript Interview Questions (Frontend + Backend)
This article covers core JavaScript concepts that every engineer must know — whether interviewing for frontend, backend (Node.js), or full-stack roles. These questions focus on the language itself, runtime behavior, memory, async patterns, and cross-environment principles.
1. JavaScript Fundamentals
These are universal to all JS environments.
Key Topics
- Scopes & closures
- Hoisting
thisbinding rules- Prototypal inheritance
- Modules: CommonJS vs ESM
- Pure vs impure functions
- Immutability vs mutability
Sample Questions
- What are closures? Provide real-world use cases.
- What is hoisting and how does it work for variables vs functions?
- Explain all 4 rules of
thisbinding. - What is prototypal inheritance? How does it differ from class inheritance?
- What is the difference between
==and===? - What is the difference between
undefinedandnull?
2. The Event Loop (Browser + Node)
This is the single most important shared topic.
Topics to Know
- Call stack, heap
- Web APIs vs Node APIs
- Macrotasks vs microtasks
- Rendering steps (browser)
- libuv phases (Node)
setTimeoutvssetImmediatevsprocess.nextTick
Sample Questions
- Explain the difference between microtasks and macrotasks.
- Predict the output of code involving Promises,
setTimeout, and async/await. - What is the difference between the browser event loop and Node's event loop?
- Why does long synchronous code block both frontend and backend environments?
3. Async Patterns (Universal)
Async JS is at the heart of frontend & backend behavior.
Sample Questions
- Compare callbacks vs promises vs async/await.
- Why is error handling with async/await tricky?
- What is a race condition in JavaScript?
- Explain
Promise.allvsPromise.racevsPromise.allSettled. - What is event delegation and why is it useful in async-heavy UIs?
- How do you cancel an asynchronous operation?
4. Memory, Performance & Garbage Collection
Memory fundamentals matter in both browser and backend.
Key Topics
- Memory allocation
- Garbage collection (mark and sweep)
- Leaks via closures, global objects, DOM references
- High CPU load impact on the event loop
Sample Questions
- How does garbage collection work in V8?
- What causes memory leaks in JS?
- How will a memory leak affect your frontend performance? How about a Node server?
- Explain tail call optimization. Does JavaScript support it?
5. Security (Shared Concepts)
Topics
- Prototype pollution
- XSS (relevant to both FE & BE template rendering)
- CSRF (relevant to full-stack or API design)
- Safe handling of
JSON.parse - Avoiding insecure eval or dynamic code execution
Sample Questions
- What is prototype pollution and how do you prevent it?
- Why is
innerHTMLdangerous even on backend-rendered templates? - What is CORS and how does it work at a high level?
- What is CSRF? When is it applicable?
6. Functional Programming Concepts
These concepts apply everywhere modern JS is written.
Sample Questions
- What is a pure function?
- What is referential transparency?
- What is currying? Provide an example.
- What are higher-order functions?
- How does immutability help avoid bugs?
7. Error Handling
Sample Questions
- Difference between
throwand returning an error. - What happens when a promise rejection is unhandled?
- Why is it dangerous to throw inside async functions?
- How do you perform global error handling in JavaScript?
8. Modules, Bundling & Build Systems
Relevant to both environments.
Sample Questions
- Difference between ESM and CommonJS.
- Explain tree shaking. What does it require?
- What is a polyfill? When do you need one?
- What are source maps?
9. JSON, Data Structures & Serialization
Sample Questions
- Why is JSON not allowed to contain functions?
- How do you deep clone an object (without libraries)?
- What are the limitations of
JSON.stringify? - Explain structured cloning.
10. Coding Problems (Common)
- Implement
debounceandthrottle. - Flatten a deeply nested JavaScript array.
- Implement a simple event emitter.
- Implement
Promise.all. - Build a retry wrapper for async functions.
- Write a memoization function.
11. Take-Home Assignments
These assignments test universal JS skills.
- Build a small in-memory cache system.
- Implement a simple pub/sub system.
- Build a JSON-based config loader with validation.
- Implement an async queue with concurrency limits.