JavaScript Interview Questions
1. What is the difference between var, let, and const?
- Explain scope, hoisting, and reassignment.
2. What are closures in JavaScript?
- Give an example and explain how inner functions can access outer scope variables.
3. What is the difference between == and ===?
- Explain type coercion and strict equality.
4. What are arrow functions and how are they different from regular functions?
- Especially differences in 'this' binding.
5. Explain the event loop in JavaScript.
- Include concepts of call stack, Web APIs, task queue, and microtasks.
6. What is the difference between null and undefined?
7. How does prototypal inheritance work in JavaScript?
- Mention __proto__, Object.create, and prototype chains.
8. What are promises and async/await in JavaScript?
- How do they help in writing asynchronous code?
9. What is a debounce and throttle function? How are they different?
- Useful in performance optimization for events like scroll or resize.
10. What are higher-order functions in JavaScript?
- Provide examples like map, filter, and custom ones.