yaoningvital / blog

my blog
31 stars 4 forks source link

React examination questions - Q3 #221

Open yaoningvital opened 4 years ago

yaoningvital commented 4 years ago

Q3、以下代码,最终执行结果是什么?为什么?

const promise = new Promise((resolve, reject)=>{
    console.log(1)
    resolve()
    console.log(2)
})

promise.then(()=>{
    console.log(3)
})

console.log(4)

Answer

1
2
4
3