事件循环题目,看这一道题就行

34 阅读1分钟
async function async1(){
    console.log('async1 start') 
    await async2()
    console.log('async1 end')
}

async function async2(params) {
    console.log('asycn2')
}

console.log('script start')

setTimeout(()=>{
    console.log('setTimeout1')
},0)

console.log('script start')

setTimeout(()=>{
    console.log('setTimeout2')
},200)

setImmediate(()=>{
    console.log('setImmediate')
})

process.nextTick(()=>console.log('nettick1'))

async1()

process.nextTick(()=>console.log('nettick2'))

new Promise((res)=>{
    console.log('promise1')
    res()
    console.log('promise2')
}).then(()=>{
    console.log('promise3')
})

console.log('script end')

image.png

image.png