JavaScript interview questions
Here’s a comprehensive list of the most frequently asked JavaScript interview questions for
someone with 4 years of experience — including core concepts, advanced topics, and real-world
coding challenges you might face in MNC or product-based interviews.
🧠 1. Core JavaScript Concepts
These form the base — interviewers often go deep into how things really work under the hood.
✅ Frequently Asked Questions:
1. What are closures? How do they work?
Explain lexical scoping and inner functions accessing outer scope variables.
2. What is hoisting?
How var, let, and const behave differently.
3. What are the differences between var, let, and const?
4. Explain the concept of the execution context and call stack.
5. What is the difference between synchronous and asynchronous code?
6. Explain event loop, microtasks, and macrotasks.
Often asked with a tricky snippet like:
js
[Link]('1');
setTimeout(() => [Link]('2'));
[Link]().then(() => [Link]('3'));
[Link]('4');
7. What is the difference between == and ===?
8. Explain how this works in different contexts.
Global, arrow functions, methods, event handlers, etc.
9. What are arrow functions and how are they different from normal functions?
10. What is the difference between shallow and deep copy?
Methods like [Link](), spread operator, structuredClone().
⚙️ 2. Advanced JavaScript
These are commonly asked for senior or mid-level roles (4+ years).
✅ Topics:
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/5
1. Prototypal Inheritance
Explain how inheritance works in JS and what __proto__ and prototype mean.
2. What is the difference between call(), apply(), and bind()?
3. Explain Currying in JavaScript.
Example:
js
function add(a) {
return function(b) {
return a + b;
};
}
4. What is memoization and how would you implement it?
5. What are generators and iterators?
How does yield work?
6. What is debouncing and throttling?
Implementation examples for optimizing scroll or input events.
7. Explain async/await vs Promises.
8. What happens when you use new keyword in JS?
9. What is event delegation and why is it useful?
10. Explain how garbage collection works in JS.
🧩 3. Data Structures & Algorithms (in JS)
✅ Common Coding Challenges:
1. Reverse a string or array.
2. Find the first non-repeating character in a string.
3. Implement debounce and throttle functions.
4. Flatten a nested array or object.
5. Deep clone an object.
6. Find duplicates in an array.
7. Implement custom versions of:
[Link]()
[Link]()
[Link]()
8. Check if two objects are deeply equal.
9. Implement a promise chain or a custom [Link]().
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/5
10. Write an LRU cache or memoize function.
🌐 4. Browser & DOM Questions
✅ Topics:
1. How does the browser render a web page (critical rendering path)?
2. What is the difference between localStorage, sessionStorage, and cookies?
3. Explain event capturing and bubbling.
4. What is the difference between [Link]() and getElementById()?
5. What is CORS and how do you handle it?
6. What are Web Workers?
7. How to prevent memory leaks in JavaScript?
8. Explain the difference between DOMContentLoaded and load events.
🔐 5. ES6+ Features
These come up very often.
✅ Topics:
1. Destructuring
2. Spread/rest operators
3. Template literals
4. Default parameters
5. Modules (import/export)
6. Classes and inheritance
7. Optional chaining ?.
8. Nullish coalescing ??
9. Map, Set, WeakMap, WeakSet
⚡ 6. Performance Optimization
1. Lazy loading and code splitting
2. Webpack and bundling
3. Tree shaking
4. Memory optimization
5. Avoiding reflows/repaints in DOM manipulation
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/5
🧩 7. Practical Scenario Questions
Interviewers often ask these to assess real-world problem-solving:
1. How do you handle asynchronous errors globally?
2. How would you retry a failed API request?
3. How would you make multiple API calls in parallel and handle results?
4. Explain how you would optimize a slow web app.
5. How do you handle large data sets efficiently in the browser?
🧮 8. Sample Coding Questions
You should be able to solve these in under 10–15 minutes:
1. Implement a debounce function
2. Implement a throttle function
3. Flatten nested arrays
4. Write a custom [Link]
5. Implement a deep clone
6. Find the missing number in an array
7. Group an array of objects by key
8. Implement function currying
9. Reverse words in a sentence
10. Remove duplicates from an array
🧱 9. Trick / Conceptual Questions
1. What will be the output?
js
var a = {};
var b = a;
a.x = 10;
a = null;
[Link](b.x);
(Answer: 10)
2. What’s the difference between:
js
function a() {}
const b = function() {}
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/5
const c = () => {}
3. Explain why this happens:
js
[Link]([] + []); // ""
[Link]([] + {}); // "[object Object]"
[Link]({} + []); // 0
🧰 10. Bonus (If you work with React / [Link])
Interviewers often test how your JavaScript understanding connects to frameworks.
React-focused:
How does reconciliation work?
Why is immutability important in React?
How does useEffect cleanup work?
What are closures in hooks?
[Link]-focused:
Event loop in Node vs browser.
How to handle async errors.
Difference between blocking and non-blocking I/O.
Would you like me to create a PDF “JavaScript Interview Handbook (4+ Years)” with these questions
and short answers (ready to revise before interviews)?
I can make it cleanly formatted for offline use.
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/5