lzcdev / Daily-Front-End-Questions

每日前端面试题、技巧等知识点,记录自己的成长过程
MIT License
1 stars 0 forks source link

输出什么?(Event Loop) #10

Open lzcdev opened 5 years ago

lzcdev commented 5 years ago
async function a1() {
    console.log('a1 start')
    await a2()
    console.log('a1 end')
}

async function a2() {
    console.log('async a2')
}

console.log("script start")

setTimeout(function() {
    console.log('setTimeOut')
},0)

a1()

new Promise(function(resolve) {
    console.log('promise1')
    resolve()
}).then(function(){
    console.log("promise2")
})
console.log('script end')