AceDevHub
Beginner JavaScript Interview QuestionsBeginnerConcept

JavaScript · Question 29

What are async and await in JavaScript?

Direct answer

async/await is Promise-based syntax that lets asynchronous control flow be written in a sequential style; an async function always returns a Promise.

Marking a function async makes its return value become a Promise result. Inside an async function, await pauses that function's continuation until the awaited value is resolved, without blocking the JavaScript thread itself.

For example, const response = await fetch(url); waits within the async function for the fetch promise to settle before continuing to the next statement.

  • Use try/catch when you want conventional-looking error handling around awaited operations.
  • Independent asynchronous operations should not always be awaited one after another; doing so can accidentally serialize work.
  • async/await does not replace Promises—it is built on Promise semantics.