本文最后更新于 2024-03-23T16:32:39+00:00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| async function async1() { console.log('async1 start') await async2() console.log('async1 end') }
async function async2() { console.log('async2') }
console.log('script start')
setTimeout(() => { console.log('setTimeout') })
async1()
new Promise(resolve => { console.log('promise1') resolve() }).then(() => { console.log('promise2') })
console.log('script end')
|
参考资料:13、事件循环是什么? - 掘金
6、异步任务打印顺序
https://mrhzq.github.io/职业上一二事/前端面试/每日一题/6、异步任务打印顺序/