1. nextTick first
process.nextTick callbacks run before the Promise microtask queue, so this logs first.
process.nextTick(() => console.log('1: nextTick'));Typorithm · hard
Step 1 of 8 · intro card
Event Loop
process.nextTick callbacks run before the Promise microtask queue, and both queues drain completely between every event-loop phase (and right after the current operation finishes). Because nextTick runs ahead of everything, recursively scheduling it can starve the loop and never let I/O or timers run.
process.nextTick callbacks have the highest priority: they run before the Promise microtask queue, so a nextTick scheduled alongside a resolved promise always logs first.
Both the nextTick queue and the microtask queue are fully drained after the current operation completes and again between every event-loop phase — they are not tied to a single phase the way timers or setImmediate are.
Because nextTick jumps ahead of I/O and timers, recursively calling process.nextTick can starve the loop: the queue never empties, so the loop never advances to its phases and pending I/O never runs.
process.nextTick runs before the Promise microtask queue.
Both queues drain between every event-loop phase.
Recursive nextTick can starve the loop — I/O never runs.
// nextTick callbacks run BEFORE the Promise microtask queue
process.nextTick(() => console.log('1: nextTick'));
Promise.resolve().then(() => console.log('2: promise'));
setTimeout(() => console.log('3: timeout'), 0);
// output: 1: nextTick, 2: promise, 3: timeout
// nextTick + microtasks both drain between every event-loop phaseConnect each part of the code to the concept before you type.
process.nextTick callbacks run before the Promise microtask queue, so this logs first.
process.nextTick(() => console.log('1: nextTick'));Promise .then callbacks are microtasks, drained after the nextTick queue but before any timer.
Promise.resolve().then(() => console.log('2: promise'));nextTick beats the promise microtask, and both run before the timers-phase setTimeout(0).
// output: 1: nextTick, 2: promise, 3: timeoutBoth the nextTick queue and the microtask queue are emptied between every event-loop phase and after the current operation.
// nextTick + microtasks both drain between every event-loop phaseRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.