Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setImmediate(function(){
- console.log(1);
- },0);
- setTimeout(function(){
- console.log(2);
- },0);
- new Promise(function(resolve){
- console.log(3);
- resolve();
- console.log(4);
- }).then(function(){
- console.log(5);
- });
- console.log(6);
- process.nextTick(function(){
- console.log(7);
- });
- console.log(8);
- // Output: 3 4 6 8 7 5 2 1
- // macrotasks: script(整体代码),setTimeout, setInterval, setImmediate, I/O, UI rendering
- // microtasks: process.nextTick, Promises, Object.observe, MutationObserver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement