What is the purpose of the async keyword in JavaScript?

What is the purpose of the async keyword in JavaScript?

a) To define a function that always returns a promise
b) To execute synchronous code
c) To delay the execution of a function
d) To wait for an event to happen

Answer:

a) To define a function that always returns a promise

Explanation:

The async keyword is used to define an asynchronous function, which always returns a promise. When an async function is called, it returns a promise, and you can use await to wait for the promise to resolve.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

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

Scroll to Top