每日一题之eventloop执行顺序
从即日起,小编将会在每天推出一道面试必备题目,日积月累,定能让你在下一次面试的时候拿到更好的
offer
,一起努力吧
今日题目
请问以下代码输出顺序是什么?
async function async1() {
console.log("async1 start");
await async2();
console.log("async1 end");
}
async function async2() {
console.log( 'async2');
}
console.log("script start");
setTimeout(function () {
console.log("settimeout");
});
async1()
new Promise(function (resolve) {
console.log("promise1");
resolve();
}).then(function () {
console.log("promise2");
});
setImmediate(()=>{
console.log("setImmediate")
})
process.nextTick(()=>{
console.log("process")
})
console.log('script end');