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);
})
解题思路:在执行return Promise.resolve(4);后会排队在往后跳两次队列的首位,别问为啥,问就是固定写法,先记下来能应付面试就行了。
setTimeout(() => {
console.log("1")
setTimeout(() => {
console.log(222222222)
}, 0)
Promise.resolve().then(() => {
console.log(666)
}).then(()=>{
console.log(7777);
})
}, 0)
new Promise((resolve) => {
console.log("2")
resolve()
}).then(() => {
console.log("3")
}).then(() => {
console.log(555)
})