【Promise第11题】
参考答案
结论
Promise.resolve(x).then(fn) 中 fn 一定异步执行;即使 x 已解决。
console.log(1);
Promise.resolve().then(() => console.log(2));
console.log(3);
// 1 3 2
若题目中混入 async/await,注意 await 等价于 then,同样推迟。
【Promise第11题】
Promise.resolve(x).then(fn) 中 fn 一定异步执行;即使 x 已解决。
console.log(1);
Promise.resolve().then(() => console.log(2));
console.log(3);
// 1 3 2
若题目中混入 async/await,注意 await 等价于 then,同样推迟。
本题来自 计算机知识面试题库,共 921 道题。