Curriculum / Final / Lesson 29

JavaScript Interview Questions

Most asked JavaScript interview questions with detailed answers and explanations.

29 of 30
advanced 📖 12 min read 🎯 5 questions

Top JavaScript Interview Questions

Here are the most commonly asked JavaScript interview questions with detailed answers. Practice these to ace your next interview.

💡 Interview Tip Don't just memorize answers — understand the underlying concepts. Interviewers often ask follow-up questions to test your depth of understanding.

Question 1: What is the difference between let, const, and var?

Answer:

var x = 1;     // function-scoped
let y = 2;     // block-scoped
const z = 3;   // block-scoped, cannot reassign

Question 2: What is the difference between == and ===?

Answer:

5 == '5'   // true (type coercion)
5 === '5'  // false (different types)
0 == false // true
0 === false // false

Question 3: What is a closure?

Answer:

A closure is a function that remembers its lexical scope even when executed outside that scope. Every function in JavaScript is a closure.

function outer() {
  let message = "Hello";
  function inner() {
    console.log(message); // remembers 'message'
  }
  return inner;
}
const fn = outer();
fn(); // "Hello"

Question 4: What is the event loop?

Answer:

The event loop is a mechanism that handles asynchronous operations in JavaScript. It continuously checks if the call stack is empty and moves tasks from the task queue and microtask queue to the call stack.

Question 5: What is the difference between null and undefined?

Answer:

let x;        // undefined
let y = null; // null
console.log(typeof null); // "object"

More Interview Questions

Practice these additional questions:

Quick Quiz

1. What is the result of typeof null?

2. Which of these is block-scoped?

3. What does 5 === '5' return?

4. What is a closure?

5. Which runs first: Promise or setTimeout?

Summary

Back to curriculum