JavaScript MCQs with answers Page - 141

Here, you will find a collection of MCQ questions on JavaScript. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833K Points
Coach

Q. Which has higher priority in JavaScript event loop?

  • (A) microtasks
  • (B) macrotasks
  • (C) DOM events
  • (D) Timers

A

Admin • 833K Points
Coach

Q. What does setInterval() do?

  • (A) Calls a function repeatedly at specified intervals
  • (B) Runs code only once after delay
  • (C) Stops execution
  • (D) Loops through array

A

Admin • 833K Points
Coach

Q. What is the role of clearTimeout()?

  • (A) Cancels a timer set by setTimeout()
  • (B) Stops event propagation
  • (C) Clears the event queue
  • (D) Stops the event loop

A

Admin • 833K Points
Coach

Q. Which method is used to add an event listener in JavaScript?

  • (A) addEventListener
  • (B) onEvent
  • (C) listenTo
  • (D) eventAttach

A

Admin • 833K Points
Coach

Q. What is event delegation?

  • (A) Using a parent element to handle events for its children
  • (B) Delegating events to the OS
  • (C) Using multiple event listeners
  • (D) Broadcasting events

A

Admin • 833K Points
Coach

Q. Which method is used to prevent the default action of an event?

  • (A) preventDefault()
  • (B) stopDefault()
  • (C) halt()
  • (D) cancelEvent()

A

Admin • 833K Points
Coach

Q. Which method stops event propagation in the DOM?

  • (A) stopPropagation()
  • (B) preventDefault()
  • (C) cancelBubble()
  • (D) haltEvent()

A

Admin • 833K Points
Coach

Q. Which JavaScript property refers to the element that triggered the event?

  • (A) event.target
  • (B) event.source
  • (C) event.trigger
  • (D) event.origin

A

Admin • 833K Points
Coach

Q. Which function is used to delay execution of code by a given time?

  • (A) setTimeout()
  • (B) delay()
  • (C) wait()
  • (D) sleep()

A

Admin • 833K Points
Coach

Q. What is the main thread in JavaScript?

  • (A) The single thread where JavaScript code executes
  • (B) A thread that handles HTTP requests
  • (C) A parallel execution thread
  • (D) The UI thread