-
-
Save iam-peekay/c75eb8a4d64c4976eacb3e813cd0526f 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 x = 10; | |
function foo() { | |
var y = x + 5; | |
return y; | |
} | |
function bar() { | |
var x = 2; | |
return foo(); | |
} | |
function main() { | |
foo(); // Static scope: 15; Dynamic scope: 15 | |
bar(); // Static scope: 15; Dynamic scope: 7 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
foo() will always return 15