极客时间返利平台,你可以在上边通过山月的链接购买课程,并添加我的微信 (shanyue94) 领取返现。

# 以下输出顺序多少 (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

欢迎在 Gtihub Issue 中回答此问题: Issue 396 (opens new window)

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

Last Updated: 11/27/2021, 6:11:48 PM