CodePeek
Practice / AsyncBack to CodePeek

JavaScript Microtasks: The tiny queue

Puzzle 14 of 15 · Microtasks

Trace synchronous logs, a resolved Promise callback and a zero-delay timer. Predict the output order across microtasks and timer tasks. Choose an output below, then check the explanation. No signup needed. Browse puzzles by topic →

Async / MicrotasksJavaScript
console.log("A");
setTimeout(() => console.log("B"), 0);
Promise.resolve().then(() => console.log("C"));
console.log("D");

Predict the console output. Each line is a separate log.

What’s the output?

Choose the output

Starter puzzles 15