console.log(1)
async function AA() {
console.log(4)
await BB()
console.log(2)
await CC()
console.log(3)
}
async function BB() {
console.log(5)
}
async function CC() {
console.log(6)
}
AA()
console.log(7)
// 1 4 5 2 7 6 3 ---错误
// 1 4 5 7 2 6 3 ---正确
// 执行await BB()时,BB函数的代码会当作是同步代码执行,但await BB()后面的代码会加入到微任务队列中,因此会优先执行同步代码console.log(7)