Skip to content
New issue

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实现存在的问题 #1

Open
luckyscript opened this issue Mar 11, 2018 · 1 comment
Open

用 setTimeout实现存在的问题 #1

luckyscript opened this issue Mar 11, 2018 · 1 comment

Comments

@luckyscript
Copy link

setTimeout(() => {
    console.log(1)
}, 0)
let timeout = new Promise((resolve, reject) => {
    console.log(2)
})

这段代码,原生输出 2 1

@fall-wind
Copy link

setTimeout(function() {
	console.log('three')
}, 0)

Promise.resolve().then(function() {
	console.log('two')
})

console.log('one')

同样的原生输出one two three;这应该是宏任务与微任务的执行顺序问题,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants