50 JavaScript Interview Questions & Answers (2025 Edition) – Crack Any Frontend Role!
1. What is Hoisting in JavaScript?
Answer: Hoisting is JavaScript’s default behaviour of moving declarations (not initializations) to the top of their scope before code execution.
Only var declarations are hoisted. let & const are also hoisted but stay in Temporal Dead Zone (TDZ).
// Example console.log(a); // undefined var a = 10; console.log(b); // ReferenceError: Cannot access 'b' before initialization let b = 20;
2. What is the difference between var, let and const?
Answer:
var→ function-scoped, hoisted, can be re-declared & updatedlet→ block-scoped, hoisted (TDZ), cannot be re-declared, can be updatedconst→ block-scoped, hoisted (TDZ), cannot be re-declared nor re-assigned (but object properties can be mutated)
3. Explain this keyword with all possible cases.
Answer:
- Global context →
window(non-strict) /undefined(strict) - Object method → refers to the object
- Simple function →
undefinedin strict mode - Arrow function → inherits
thisfrom enclosing lexical scope call / apply / bind→ explicitly set- Event listener → refers to the DOM element
4. What is Closure? Give a practical example.
Answer: A closure is a function that remembers its outer variables even after the outer function has returned.
function createCounter() {
let count = 0;
return function() {
return ++count;
}
}
const counter = createCounter();
console.log(counter()); // 1
console.log(counter()); // 2
5. Explain Event Loop in simple words.
Answer: Event Loop has one job: check if Call Stack is empty → if yes, push the first task from Callback Queue (or Microtask Queue) is pushed to Call Stack.
Priority: Microtask Queue (Promises, MutationObserver) > Callback Queue (setTimeout, DOM events).
6. What will be the output?
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => console.log('3'));
console.log('4');
Answer: 1 → 4 → 3 → 2
7. Difference between == and ===?
== does type coercion, === checks value and type both (strict equality).
8. What is Prototype Inheritance?
Every object in JS has a hidden [[Prototype]] property that points to another object (or null). This chain is used for property lookup.
9. Explain async/await vs Promises.
async/await is syntactic sugar over Promises – makes asynchronous code look synchronous and easier to read.
10. What are Higher-Order Functions?
Functions that take other functions as arguments or return a function (map, filter, reduce, etc.).
11–50 Quick List (Full answers available in downloadable PDF below)
- What is Debouncing and Throttling?
- Explain Call, Apply and Bind with example
- What is Currying?
- Difference between
nullandundefined - What are Promises? States?
- Promise.all vs Promise.allSettled vs Promise.race
- What is Event Bubbling and Capturing?
- How to stop propagation?
- What is
event.targetvsevent.currentTarget? - Explain
fetchAPI and how to handle errors - What are Modules in JavaScript (ES6 import/export)?
- Difference between
module.exportsandexport default - What is the use of
strict mode? - Explain IIFE with example
- What is Temporal Dead Zone (TDZ)?
- Explain Spread vs Rest operator
- What are Arrow functions limitations?
- Difference between
forEachandmap - What is NaN and how to check it?
- Explain
Object.freeze()vsObject.seal() - What are Generators?
- Explain
Symboldata type - What is Proxy and Reflect?
- Difference between
deleteandundefined - What is Memoization?
- How does Garbage Collection work in JS?
- What is
Optional Chaining (?.)andNullish Coalescing (??)? - Explain
BigInt - What are WeakMap and WeakSet?
- Difference between
localStorageandsessionStorage - How to deep clone an object?
- What is
Array.flat()andArray.flatMap()? - Explain
Promise.any()andPromise.withResolvers() - What are Top-Level Awaits?
- How to handle memory leaks in JavaScript?
- What is the difference between
slice()andsplice()? - Explain
reduce()with real-world example - What is
event delegation> and why use it? - How does
JSON.stringifyandJSON.parsework with circular references? - What are Service Workers?
- Explain CORS and how to fix it
- What is Tree Shaking?
- Difference between
typeofandinstanceof - How to detect dark mode in JavaScript?
- What is the purpose of
Object.hasOwn()(new in ES2022)? - Explain
Private class fields(#) - What are JavaScript Design Patterns you know?
- How would you implement inheritance in ES6 classes?
- Explain the most tricky question you faced in interview? (Bonus 😄)

Save this page – 99% of JavaScript interviews in 2025 revolve around these 50 questions!
JavaScript Interview 2025
Frontend Interview Questions
Hoisting Closures Event Loop
React Angular Vue Prep
Virat Kohli and Rohit Sharma’s ODI Future: BCCI VP Rajiv Shukla Slams Farewell Rumors
