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

macrotask和microtask的疑问 #2

Open
Oscar19921030 opened this issue Apr 9, 2018 · 1 comment
Open

macrotask和microtask的疑问 #2

Oscar19921030 opened this issue Apr 9, 2018 · 1 comment

Comments

@Oscar19921030
Copy link

Oscar19921030 commented Apr 9, 2018

console.log(1);
setTimeout(() => { console.log(2) }, 0);
Promise.resolve()
.then(() => { console.log(3) })
.then(() => { console.log(4) })
.then(()=>{console.log(6)})
console.log(5);
这串代码在chrome浏览器中能够符合文章中的macrotask和microtask运行优先级的说法;但是放到Safari中就很诡异
safari版本 10.0.3 (12602.4.8)

@nekronhuang
Copy link

nekronhuang commented Apr 9, 2018

@Oscar19921030 因为精力有限,所以没有去深入研究Safari的原理哈,文中也提到了只针对chrome哈~

这个例子我在safari 11下挺正常的?

不过有个东西,我为了不让概念太多导致混乱,特意没做展开,叫做Job。Safari目前是将Promise定义为Job的,而Job的规范是:

Execution of a Job can be initiated only when there is no running execution context and the execution context stack is empty…

这里写的是can be,所以行为不要太离谱,都能接受。。。

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