Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. var log = console.log
  2.  
  3. log("Inside global execution context")
  4.  
  5. function functionOne() {
  6. log("Inside function one")
  7.  
  8. function setTimeoutFunction() {
  9. log("Inside setTimeoutFunction: I will be executed atleast after 1 sec")
  10. }
  11.  
  12. setTimeout(setTimeoutFunction, 1000)
  13.  
  14. for(var i = 0; i < 10000000000; i++) {
  15. // Blocking code. This makes the for loop to execute for more than 1 second
  16. // Still setTimeoutFunction is not executed. It gets executed only after
  17. // last statement of the code
  18. }
  19.  
  20. log("Exiting functionOne")
  21. }
  22.  
  23. functionOne()
  24.  
  25. log("Exiting global execution context")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement