📚 8.奇怪的输出题
💻 代码实现
typescript
// Promise.resolve()
// .then(() => {
// console.log(0)
// return 4
// })
// .then(console.log)
// Promise.resolve()
// .then(() => {
// console.log(1)
// })
// .then(() => {
// console.log(2)
// })
// .then(() => {
// console.log(3)
// })
// .then(() => {
// console.log(5)
// })
// .then(() => {
// console.log(6)
// })
// 0 1 4 2 3 5 6
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)
})
// https://juejin.cn/post/6949699310732869669