ytxmobile

JavaScript Promise & setTimeOut demo

Aug 9th, 2021 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. setTimeout(function() {
  2.   console.log(1)
  3. }, 0);
  4.  
  5. new Promise(function(resolve) {
  6.   console.log(2);
  7.   for( var i=0 ; i<10000 ; i++ ) {
  8.     i == 9999 && resolve();
  9.   }
  10.   console.log(3);
  11. }).then(function() {
  12.   console.log(4);
  13. });
  14.  
  15. console.log(5);
Add Comment
Please, Sign In to add comment