JavaScript Objective Questions and Answers - Set 2

This JavaScript quiz contains carefully curated objective questions with correct answers and clear explanations. It is designed for frontend and backend developers, interview preparation, and deep understanding of modern JavaScript concepts including ES6+, asynchronous behavior, scope, closures, and performance pitfalls. This is part 2 of the series.

Practice JavaScript MCQs with Detailed Explanations

Answer at least 12 questions to submit and verify answers.

16 Which queue executes first in the event loop? High

17 What is the output? Promise.resolve(1) .then(x => x + 1) .then(x => { throw x; }) .catch(err => console.log(err)); High

18 Which statement about prototypes is correct? Medium

19 What does this keyword refer to inside an arrow function? Medium

20 What is the output? console.log(typeof (() => {})); Medium

21 What will be the output order? console.log('A'); setTimeout(() => console.log('B')); Promise.resolve().then(() => console.log('C')); console.log('D'); High

22 What is the output? async function test() { return 5; } console.log(test()); Medium

23 What does await do internally? High

24 Which causes a memory leak in JavaScript? High

25 What is the output? let a = { x: 1 }; let b = a; a = null; console.log(b.x); Medium

26 Which comparison avoids type coercion? Medium

27 What will be logged? console.log(1 + '2' + 3); Medium

28 What is the output? console.log(true + false); Medium

29 Which object is responsible for garbage collection? High

30 What happens if a Promise is neither resolved nor rejected? Medium