$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #253

What is the output?

async function f() {
  console.log(1);
  await null;
  console.log(2);
}
f();
console.log(3);
  1. 1 2 3
  2. 3 1 2
  3. 2 1 3
  4. 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 ▸