JavaScript MCQs with answers Page - 139

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 method is used to handle a resolved Promise?

  • (A) then()
  • (B) catch()
  • (C) resolve()
  • (D) finally()

A

Admin • 833K Points
Coach

Q. Which method is used to handle errors in Promises?

  • (A) catch()
  • (B) then()
  • (C) error()
  • (D) fail()

A

Admin • 833K Points
Coach

Q. What is the purpose of async keyword in JavaScript?

  • (A) To define a function that returns a Promise
  • (B) To pause code execution
  • (C) To define synchronous code
  • (D) To create event loops

A

Admin • 833K Points
Coach

Q. What is the purpose of the await keyword?

  • (A) To wait for a Promise to resolve
  • (B) To block the main thread
  • (C) To delay function execution
  • (D) To create a loop

A

Admin • 833K Points
Coach

Q. Which JavaScript feature allows function to access variables from an outer scope?

  • (A) Closure
  • (B) Scope chain
  • (C) Callback
  • (D) Hoisting

A

Admin • 833K Points
Coach

Q. Which keyword is used to define a class in JavaScript?

  • (A) class
  • (B) object
  • (C) structure
  • (D) function

A

Admin • 833K Points
Coach

Q. How do you create an instance of a class?

  • (A) new ClassName()
  • (B) create ClassName()
  • (C) object ClassName()
  • (D) instanceof ClassName()

A

Admin • 833K Points
Coach

Q. Which method is automatically called when a new object is created?

  • (A) constructor
  • (B) init
  • (C) create
  • (D) build

A

Admin • 833K Points
Coach

Q. What is lexical scope?

  • (A) Scope determined at compile time based on code structure
  • (B) Scope determined at runtime
  • (C) Scope of a function inside a loop
  • (D) Scope within a class

A

Admin • 833K Points
Coach

Q. What will be the output of: typeof Promise?

  • (A) function
  • (B) object
  • (C) undefined
  • (D) promise

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ