Advertisement
STANAANDREY

sleep js

Apr 24th, 2022 (edited)
1,944
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const sleep = delay => new Promise(resolve => {
  2.     setTimeout(resolve, delay);
  3. })
  4.  
  5.     window.onload = () => {
  6.         sleep(1000).then(async () => {
  7.             await sleep(500);
  8.             console.log('printd after 1500ms');
  9.         })
  10.        
  11.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement