We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setTimeout(() => { console.log('timer1') setTimeout(() => { console.log('timer3') }, 0) }, 0) setTimeout(() => { console.log('timer2') }, 0) console.log('start') // start, timer1,timer2,timer3
setTimeout(() => { console.log('timer1') Promise.resolve().then(() => { console.log('promise') }) }, 0) setTimeout(() => { console.log('timer2') }, 0) console.log('start') // start, timer1,promise,timer2
timer3
Promise.then
timer2
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Promise 题目 2 - 3 - 1
过程分析
一个是为定时器
timer3
, 一个是为Promise.then
timer3
的话, 它会在timer2
后执行, 而Promise.then
却是在timer2
之前执行.Promise.then
是微任务, 它会被加入到本轮中的微任务列表, 而定时器timer3
是宏任务, 它会被加入到下一轮的宏任务中.The text was updated successfully, but these errors were encountered: