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"); 12 13setTimeout(function() { 14 console.log("setTimeout"); 15}, 0); 16 17async1(); 18 19new Promise(function(resolve) { 20 console.log("promise1"); 21 resolve(); 22}).then(function() { 23 console.log("promise2"); 24}); 25console.log('script end') 26
参考答案:
经过前面的题目解析,相信这道题可以很容易得出结果。
'script start'
'async1 start'
'async2'
'promise1'
'script end'
'async1 end'
'promise2'
'setTimeout'
最近更新时间:2022-01-09