async function fn1 (){
console.log(1)
await fn2()
console.log(2) // 阻塞
}
async function fn2 (){
await fn3 ()
console.log('fn2')
}
async function fn3 (){
await console.log('fn3')
}
async function fn4 (){
await console.log(4)
console.log('fn4')
}
fn4 ()
fn1()
new Promise((resolve)=>{
console.log('promise')
resolve()
}).then(()=>{
console.log('then1')
})
new Promise((resolve)=>{
resolve()
}).then(()=>{
console.log('then2')
})
setTimeout(()=>{
console.log('setTimeout')
})
console.log(3)
//同步
4
1
fn3
//promise
3
//微任务
//.then
fn4
//.then.then await fn(),会发生阻塞,先执行async外的代码,结果顺序为 fn->2
2
fn2
//then1
//then2
//宏任务
setTimeout
console