Phase 10 taught the task queue (macrotasks) for timers. Promise handlers use a separate microtask queue. After the current stack empties, the engine drains microtasks before the next timer task. So: sync → promise .thensetTimeout.

Call stack

    Microtasks

      Task queue

        Press Run — expect: A, C, then promise B, then timeout D.

        Idle.

        Important JavaScript

        console.log("A");
        
        Promise.resolve().then(function () {
          console.log("B"); // microtask
        });
        
        console.log("C");
        
        setTimeout(function () {
          console.log("D"); // macrotask
        }, 0);
        
        // Prints: A, C, B, D