Async & Browser JS / Async / Await
async / await
Syntax that lets promise-based code read top to bottom, like synchronous code.
`async` marks a function as always returning a promise. Inside it, `await` pauses that function's execution at the awaited expression — without blocking the rest of the program — until the awaited promise settles, then resumes with either the resolved value or a thrown error. It's the same event loop underneath; `await` is sugar over `.then()` chaining.
Codeeditable — Run executes your edits
Loading...
Console
Output will appear here
Visualization
The Event Loop
Call Stack
Web APIs
Microtasks
Task Queue
priority: call stack → drain all microtasks → one macrotask → repeat
Why?
await pauses loadUser at that line and immediately hands control back to the caller — that's why "after call" logs before data.name does, even though loadUser was called first.