πŸ”΄ HardEvent Loop & PromisesπŸ’» Output Question

async/await vs .then chain

πŸ’‘

Hint

await suspends only the current async function β€” outer sync code continues immediately.

What does this output?

async function async1() {
  console.log('async1 start');
  await async2();
  console.log('async1 end');
}

async function async2() {
  console.log('async2');
}

console.log('start');
async1();
console.log('end');

Correct Output

start
async1 start
async2
end
async1 end

Why this output?

Explanation: "start" logs. async1() called: logs "async1 start", calls async2(). async2 logs "async2" and returns. await suspends async1. Control returns to sync: "end" logs. Microtask resumes: "async1 end".

Key Insight: await suspends only the current async function β€” outer sync code continues immediately.

More Event Loop & Promises Output Questions

🟑 MediumClassic setTimeout vs Promiseβ†’πŸ”΄ HardNested setTimeout and Promiseβ†’πŸŸ‘ Mediumasync/await execution orderβ†’πŸ”΄ HardPromise chaining orderβ†’

Practice predicting output live β†’

66 output questions with instant feedback

πŸ’» Try Output Quiz