Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. setImmediate(function(){
  2. console.log(1);
  3. },0);
  4. setTimeout(function(){
  5. console.log(2);
  6. },0);
  7. new Promise(function(resolve){
  8. console.log(3);
  9. resolve();
  10. console.log(4);
  11. }).then(function(){
  12. console.log(5);
  13. });
  14. console.log(6);
  15. process.nextTick(function(){
  16. console.log(7);
  17. });
  18. console.log(8);
  19.  
  20. // Output: 3 4 6 8 7 5 2 1
  21. // macrotasks: script(整体代码),setTimeout, setInterval, setImmediate, I/O, UI rendering
  22. // microtasks: process.nextTick, Promises, Object.observe, MutationObserver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement