My answer is 0 1 2 3 5 6 4
, but the output in Chrome is 0 1 2 3 4 5 6
, I have read Tasks, microtasks, queues and schedules and I tried to understand the order of Promise
, I think I did it.
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)
})