Q. Which of the following is NOT a valid JavaScript class feature?

  • (A) private class variables using #
  • (B) static methods
  • (C) public class properties
  • (D) constructors overloading
πŸ’¬ Discuss
βœ… Correct Answer: (D) constructors overloading
Explanation: JavaScript does not support function overloading, including constructors.

Q. Which object method executes a reducer function on each element?

  • (A) reduce()
  • (B) map()
  • (C) filter()
  • (D) sort()
πŸ’¬ Discuss
βœ… Correct Answer: (A) reduce()
Explanation: reduce() applies a function against an accumulator and each element.

Q. What will console.log(typeof []) return?

  • (A) object
  • (B) array
  • (C) list
  • (D) function
πŸ’¬ Discuss
βœ… Correct Answer: (A) object
Explanation: Arrays are special objects, so typeof returns 'object'.

Q. What is the result of 2 + '2'?

  • (A) 22
  • (B) 4
  • (C) undefined
  • (D) NaN
πŸ’¬ Discuss
βœ… Correct Answer: (A) 22
Explanation: JavaScript converts 2 to a string and concatenates: '2' + '2'.

Q. Which feature allows defining class-level methods?

  • (A) static
  • (B) global
  • (C) const
  • (D) private
πŸ’¬ Discuss
βœ… Correct Answer: (A) static
Explanation: Static methods are bound to the class, not instances.

Q. How do you catch both resolved and rejected states of a Promise?

  • (A) then().catch()
  • (B) catch().then()
  • (C) done().fail()
  • (D) async()
πŸ’¬ Discuss
βœ… Correct Answer: (A) then().catch()
Explanation: Chaining then() and catch() handles both resolve and reject outcomes.

Q. Which method ensures code runs regardless of Promise result?

  • (A) finally()
  • (B) always()
  • (C) resolve()
  • (D) done()
πŸ’¬ Discuss
βœ… Correct Answer: (A) finally()
Explanation: finally() executes whether the Promise was resolved or rejected.

Q. What is the event loop in JavaScript?

  • (A) A mechanism that handles asynchronous callbacks
  • (B) A loop used to iterate over DOM elements
  • (C) A function that repeats code
  • (D) A type of loop like for or while
πŸ’¬ Discuss
βœ… Correct Answer: (A) A mechanism that handles asynchronous callbacks
Explanation: The event loop is responsible for executing asynchronous code in JavaScript.

Q. Which queue does setTimeout use?

  • (A) macrotask queue
  • (B) microtask queue
  • (C) callback queue
  • (D) event queue
πŸ’¬ Discuss
βœ… Correct Answer: (A) macrotask queue
Explanation: setTimeout schedules its callbacks in the macrotask queue.

Q. Which has higher priority in JavaScript event loop?

  • (A) microtasks
  • (B) macrotasks
  • (C) DOM events
  • (D) Timers
πŸ’¬ Discuss
βœ… Correct Answer: (A) microtasks
Explanation: Microtasks like Promise callbacks are executed before macrotasks.