- async/await是小妹异步回调的终极武器
- JS是单线程,还是有异步,还得基于event loop
- async/await只是一个语法糖
async function async1() { console.log('async1 start') await async2() // await 后面的行代码,都可以看作是 callback 里的内容,即异步 // 类似 event loop,setTimeout(cb1) // setTimeout(function () { console.log('async1 end') }) // Promise.resolve().then(() => { console.log('async1 end') }) console.log('async1 end')}async function async2() { console.log('async2')}console.log('script start')async1()console.log('script end')// script start// async1 start// async2// async1 end// script end