我正在学习 js 中的 Promise,我对此有一些疑问,这是代码:
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);
})Run Code Online (Sandbox Code Playgroud)
输出与我预期的相差甚远,我认为它会是 0 1 4 2 3 5 6,因为我在 MDN 上看到了这个
Promise.resolve() 方法返回一个使用给定值解析的 Promise 对象
那么 log() 方法不应该在数字 1 后面触发吗?
我究竟做错了什么?