Advertisement
whoisYeshua

Event Loop Advanced

Jun 15th, 2023 (edited)
765
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function async1() {
  2.   console.log('async1 start');
  3.   await async2();
  4.   console.log('async1 end');
  5. }
  6.  
  7. async function async2() {
  8.   console.log('async2');
  9. }
  10.  
  11. console.log('script start');
  12.  
  13. setTimeout(function () {
  14.   console.log('setTimeout');
  15. }, 0);
  16.  
  17. async1();
  18.  
  19. new Promise(function (resolve) {
  20.   console.log('promise1');
  21.   resolve();
  22. }).then(function () {
  23.   console.log('promise2');
  24. });
  25.  
  26. console.log('script end');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement