JavaScript Objective Questions and Answers

This JavaScript MCQ quiz contains carefully curated objective and code-based questions with correct answers and clear explanations. Ideal for beginners, experienced developers, and interview preparation, covering core JavaScript, ES6+, asynchronous programming, and DOM manipulation.

Practice JavaScript MCQs with Detailed Explanations

Answer at least 12 questions to submit.

16.
Medium
What will be logged?

function outer() {
  let x = 10;
  return function inner() {
    return x;
  };
}
console.log(outer()());
17.
Easy
Which keyword is used to create a class?
18.
Easy
Which method selects an element by ID?
19.
Medium
What is the output?

console.log(0 == false);
console.log(0 === false);
20.
Easy
Which keyword stops loop execution?
21.
Hard
What is the output?

console.log([1,2,3] + [4,5]);
22.
Medium
Which API is used to fetch data over HTTP?
23.
Easy
Which storage persists after browser close?
24.
Medium
Which operator safely accesses nested properties?
25.
Medium
Which loop iterates over object keys?
26.
Medium
What is the output?

console.log(NaN === NaN);
27.
Easy
Which method removes whitespace from both ends?
28.
Easy
Which keyword creates a constant?
29.
Easy
What is the output?

console.log(typeof function(){});
30.
Medium
Which statement prevents default browser behavior?
Answered: 0 / 15