Skip to content
快看这页儿写了啥...

No.0140

题干

js
Promise.resolve().then(() => {
  console.log(0);
  return Promise.resolve(4);
}).then((res) => {
  console.log(res);
});

Promise.resolve().then(() => {
  console.log(1);
}).then(() => { 
  console.log(2);
}).then(() => {
  console.log(3);
}).then(() => {
  console.log(5);
}).then(() => {
  console.log(6);
});

题解

js
// 0
// 1
// 2
// 3
// 4
// 5
// 6

扩展

「硬核JS」图解Promise迷惑行为|运行机制补充

贡献者

isboyjc's avatar isboyjc

浏览量(PV)  次  ·  独立访客(UV)  人次
不正经的前端 | 八股 · 欢迎 star ⭐