Frontend101 logoFrontend101
← Problems
#19MediumQuiz

19. Microtask Queue & Event Loop Order

JavaScriptAsync & Promises

Predict and verify the execution order across synchronous code, Promise.then microtasks, and setTimeout macrotasks.

Example 1:
await traceEventLoopOrder(); // ["sync", "microtask", "macrotask"]
solution.js
Executes sync, then microtask, then macrotask
(async () => {
          expect(await traceEventLoopOrder()).toEqual(["sync", "microtask", "macrotask"]);
        })()