HomoCivicus

Event Loop

Aug 11th, 2022 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. setTimeout(() => {
  2.     console.log(1);
  3. }, 0);
  4.  
  5. const promise = new Promise<void>((resolve) => {
  6.     console.log(2);
  7.     resolve();
  8. });
  9.  
  10. promise
  11.     .then(() => {
  12.         console.log('a');
  13.     })
  14.     .then(() => {
  15.         console.log('b');
  16.     })
  17.     .then(() => {
  18.         console.log('c');
  19.     });
  20.  
  21. of(null).subscribe(() => {
  22.     console.log(3);
  23. });
  24.  
  25. console.log(4);
Add Comment
Please, Sign In to add comment