Interview Question

What is async/await?

async/await is syntax built on promise-based asynchronous control flow.

💡 Concept ✅ Quick Revision ⚡ JavaScript

Answer

async functions return promises, and await pauses their evaluation until a promise settles. β€’ Returning a value fulfills the async function’s promise. β€’ Throwing rejects that promise. β€’ await resumes the async function through promise jobs without blocking the host thread.

Example

Code
async function read() {
  const value = await Promise.resolve(7);
  return value * 2;
}
read().then(console.log);
Output
14

Quick Revision

async/await is syntax built on promise-based asynchronous control flow.