fn()
console.log(1);
setTimeout(() => {
console.log(4);
}, 100);
Promise.resolve().then(()=>{
console.log(2);
})
console.log(3);
function fnPromise(){
return new Promise(resolve=>{
resolve(5)
})
}
async function fn(){
// const res = await fnPromise() //遇到await就执行紧跟的表达式,然后跳出该函数,只要await后面表达式语句有明确结果,await后一行的代码立即加入微任务队列
const res = await 51 //遇到await就执行紧跟的表达式,然后跳出该函数,只要await后面表达式语句有明确结果,await后一行的代码立即加入微任务队列
console.log('res',res);
}
result:
3
res 51
2
4
标签:resolve,console,函数,res,await,async,机制,表达式,log
From: https://www.cnblogs.com/qieting/p/17776848.html