Search for a command to run...
setTimeout 0 vs promise.then vs queueMicrotask · the canonical ordering question
The script is itself a task
Running the file is the first task of the loop. console.log prints synchronously.
Execution
1console.log('script start');//stack: 1output: 12 3setTimeout(() => {4 console.log('setTimeout 0');5}, 0);6 7Promise.resolve().then(() => {8 console.log('promise.then');9});10 11queueMicrotask(() => {12 console.log('queueMicrotask');13});14 15console.log('script end');