QuickDevGuide

Home › JavaScript

Async / Await — JavaScript

async/await (introduced in ES2017) is syntactic sugar over Promises that makes asynchronous code look and behave like synchronous code. It is the modern standard for writing async JavaScript. How It Works The async keyword marks a function as async — it automatically returns a Promise. Inside an async function, you can use the await keyword before any Promise. The execution pauses at that point until the Promise settles, then continues with the resolved value. Critically, the browser is NOT blocked — other JavaScript can run while awaiting. Error Handling Wrap await calls in try/catch blocks to handle rejections cleanly. The catch block catches both network errors and manually thrown errors. The finally block always runs — use it to clean up (hide loading spinners, close connections)…

Key Takeaways