What is the output?
async function f() {
console.log(1);
await null;
console.log(2);
}
f();
console.log(3);
- 1 2 3
- 3 1 2
- 2 1 3
- 1 3 2
An async function runs synchronously up to its first await. The rest is queued as a microtask, which runs after the current script logs 3.
Play Problem Solving ▸