The event loop and microtasks

What order do the logs appear in?

Examples

Worked example

Input
Log A, queue a zero-delay timer that logs C, then queue a resolved Promise that logs B.
Expected output
A, B, C

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

The current script logs A. The microtask logs B before the timer task can log C.

Back to the lesson