A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-57.js
1asyncfunctionf(){
2console.log(1);
3awaitnull;
4console.log(2);
5}
6console.log(0);
7f();
8console.log(3);
Async
Answer & explanation
Console output
0
1
3
2
Why
Calling an async function runs its body synchronously until the first await, then returns a pending promise. The code after await, even after awaiting a non-promise like null, is queued as a microtask. So console.log(2) is deferred until the synchronous calls (0, 1, 3) complete, then runs from the microtask queue.