Guest User

Untitled

a guest
May 26th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. setTimeout(myFunction, 3000);// if you have defined a function named myFunction it will run after 3 seconds (3000 milliseconds)
  2.  
  3. function test1()
  4. {
  5.  
  6. //some code
  7.  
  8. //Let's say JS did have a sleep function.
  9. sleep(3000); //sleep for 3 seconds,
  10.  
  11. alert('hi');
  12. }
  13.  
  14. function test2()
  15. {
  16. setTimeout(function() { alert('hello');}, 3000); //defer the execution of anonymous function for 3 seconds and go to next line of code.
  17.  
  18. alert('hi');
  19. }
Add Comment
Please, Sign In to add comment