# 以下输出顺序多少 (setTimeout 与 promise 顺序)

更多描述

setTimeout(() => console.log(0))
new Promise((resolve) => {
 console.log(1)
 resolve(2)
 console.log(3)
}).then(o => console.log(o))

new Promise(resolve => {
 console.log(4)
 resolve(5)
}).then(o => console.log(o)).then(() => console.log(6))

Issue

欢迎在 Issue 中交流与讨论: Issue 396

Author

回答者: iceytea

1 => 3 => 4 => 2 => 5 => 6 => 0

扫码关注公众号全栈成长之路,并发送

即可在关注期间无限制浏览本站全部文章内容

你也可以在文章关于回复公众号扫码解锁全站的技术实现中获得解锁代码,永久解锁本站全部文章