Last active
June 16, 2019 07:00
-
-
Save happymishra/437237ca0a3ccf70219c603e62a7012a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var log = console.log | |
log("Inside global execution context") | |
function functionOne() { | |
log("Inside function one") | |
function setTimeoutFunction() { | |
log("Inside setTimeoutFunction: I will be executed atleast after 1 sec") | |
} | |
setTimeout(setTimeoutFunction, 1000) | |
for(var i = 0; i < 10000000000; i++) { | |
// Blocking code. This makes the for loop to execute for more than 1 second | |
// Still setTimeoutFunction is not executed. It gets executed only after | |
// last statement of the code | |
} | |
log("Exiting functionOne") | |
} | |
functionOne() | |
log("Exiting global execution context") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment