JavaScript · Middle · Question 24 of 75

In what order are the lines printed?

async function f() {
  console.log("A");
  await null;
  console.log("B");
}
f();
console.log("C");

Explanation

An async function's body runs synchronously until the first await. The rest continues as a microtask after the current synchronous code finishes. So first A, then C, then B.

Further reading

Problem with a question

JavaScript · Middle · question 24

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz