How does the await keyword work in JavaScript?

How does the await keyword work in JavaScript?

a) It pauses the execution of an async function until the promise is resolved or rejected
b) It returns a promise
c) It forces a function to execute synchronously
d) It runs a function immediately

Answer:

a) It pauses the execution of an async function until the promise is resolved or rejected

Explanation:

The await keyword is used inside an async function to pause execution until a promise is resolved or rejected. This allows asynchronous code to be written in a synchronous style.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top