考察事件循环、任务队列、和setTimeout、Promise结合,以输出结果顺序的方式来考察
范例1 来自面经 第5题
async function async1(){ console.log('async1 start') await async2() console.log('async1 end') } async function async2(){ console.log('async2') } console.log('script start') setTimeout(function(){ console.log('setTimeout') },0) async1() new Promise(function(reslove){ console.log('promise1'); resolve() }).then(function(){ console.log('promise2') }) console.log('script end')