Subjects › JavaScript

Asynchrony

The event loop, promises, and async/await.

The idea

Two ideas do most of the work: the call stack must empty before any callback runs, and microtasks jump the queue ahead of timers.

Lesson

No lesson built yet. The worked solutions below are the material it would be assembled from.

Questions (3)

Question Type Difficulty Drift Accuracy
In what order does this log? console.log('A'); setTimeout(() => console.log('B'), 0); Promise.resolve().then(… mcq Hard 0.60 — — (0)
Two independent API calls each take 1 second. Which version finishes in about 1 second rather than 2? mcq Hard 1.00 — — (0)
Why does a try/catch around a synchronous call fail to catch an error thrown inside a setTimeout callback? Wha… short Very hard 1.50 — — (0)