異步相關面試
1 // 今日頭條面試題 2 async function async1() { 3 console.log('async1 start') 4 await async2() 5 console.log('async1 end') 6 } 7 async function async2() { 8 console.log('async2') 9 } 10 console.log('script start') 11 setTimeout(function () { 12 console.log('settimeout') 13 }) 14 async1() 15 new Promise(function (resolve) { 16 console.log('promise1') 17 resolve() 18 }).then(function () { 19 console.log('promise2') 20 }) 21 console.log('script end')