Example 1 — Await a Resolved Promise
Read a value from a fulfilled Promise.
async function run() {
const n = await Promise.resolve(42);
console.log(n);
}
run(); How It Works
- Pause. Execution waits until the Promise fulfills.
- Continue. Then
nis42and logging runs.
