zjtd面试题
作者:
大福爸爸_ | 来源:发表于
2020-04-01 15:09 被阅读0次async function async1() {
console.log('async 1 start'); //--------
await async2();
console.log('async1 end'); //--------
}
async function async2() {
console.log('async2'); //--------
}
console.log('script start'); //--------
setTimeout(function() {
console.log('settimeout'); //--------
},0);
async1();
new Promise(function (resolve) {
console.log('promise1'); //--------
resolve();
}).then(function() {
console.log('promise2'); //--------
});
console.log('script end'); //--------
- await和then是微任务,要在主线程结束后再执行
- settimeout是宏任务,要在微任务结束后再执行
微任务:promise async await
宏任务:定时器 事件绑定
本文标题:zjtd面试题
本文链接:https://www.haomeiwen.com/subject/gjhauhtx.html
网友评论