Search for a command to run...
The classic async1 / async2 / promise1 / setTimeout ordering question
Script starts
The two async function declarations only define functions. The first thing that runs is this log.
Execution
1async function async1() {2 console.log('async1 start');3 await async2();4 console.log('async1 end');5}6 7async function async2() {8 console.log('async2');9}10 11console.log('script start');//output: 112 13setTimeout(() => {14 console.log('setTimeout');15}, 0);16 17async1();18 19new Promise((resolve) => {20 console.log('promise1');21 resolve();22}).then(() => {23 console.log('promise2');24});25 26console.log('script end');