Async/Await — Complete Guide
Async/Await — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of JavaScript Tutorial on Toolliyo Academy.
On this page
JavaScript Tutorial · Lesson 44 of 100
Async/Await
Basics ✓ → Objects & data ✓ → Async & DOM → Advanced → Tools → Projects
Intermediate · 3 — Async & DOM · ~6 min · JS Async JavaScript
What is this?
async/await lets you write promise-based code that looks synchronous. async marks a function; await pauses until a Promise finishes.
Why should you care?
Easier to read than long .then() chains. try/catch works for errors.
See it live — copy this example
Paste into an HTML file or the browser console (F12). Use Run below when the live editor is available.
function delay(ms) {
return new Promise((r) => setTimeout(r, ms));
}
async function run() {
console.log("Start");
await delay(300);
console.log("After 300ms");
}
run();
Run Example »
Edit the code below and click Run to see the result in Toolliyo’s live editor.
What happened?
- await delay(300) waits without blocking the whole browser — only the async function pauses.
- Other events still run.
Practice next
- Run async run() and note Start / After 300ms order.
- Wrap await in try/catch with intentional throw.
- Call run() twice quickly — both run concurrently.
- Sequential await two delays and log timestamps between them.
- Use await Promise.all for two simultaneous fetches.
Remember
async function ... await promise Use try/catch for errors
ScriptVerse checkout flow
async function submitOrder awaits payment token then order creation in readable top-to-bottom code.
Outcome: async/await keeps complex flows maintainable compared to nested .then chains.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!