-
-
Save iam-peekay/77a0b6f1d353142f5ef52bc34c1857f8 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 myVar = 100; | |
function foo() { | |
console.log(myVar); | |
} | |
foo(); // Static scope: 100; Dynamic scope: 100 | |
(function () { | |
var myVar = 50; | |
foo(); // Static scope: 100; Dynamic scope: 50 | |
})(); | |
// Higher-order function | |
(function (arg) { | |
var myVar = 1500; | |
arg(); // Static scope: 100; Dynamic scope: 1500 | |
})(foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can we console it, static & dynamic scope ??