Advertisement
whoisYeshua

Promise Order 1

Jun 15th, 2023
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.34 KB | Source Code | 0 0
  1. // #Promise Order 1
  2. console.log(1)
  3. const promise = new Promise((resolve) => {
  4.   console.log(2)
  5.   resolve()
  6.   console.log(3)
  7. })
  8.  
  9. console.log(4)
  10.  
  11. promise.then(() => {
  12.   console.log(5)
  13. }).then(() => {
  14.   console.log(6)
  15. })
  16.  
  17. console.log(7)
  18.  
  19. setTimeout(() => {
  20.   console.log(8)
  21. }, 10)
  22.  
  23. setTimeout(() => {
  24.   console.log(9)
  25. }, 0)
Tags: EventLoop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement