Skip to content

Instantly share code, notes, and snippets.

@iam-peekay
Created April 27, 2016 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iam-peekay/c75eb8a4d64c4976eacb3e813cd0526f to your computer and use it in GitHub Desktop.
Save iam-peekay/c75eb8a4d64c4976eacb3e813cd0526f to your computer and use it in GitHub Desktop.
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;
}
@countcain
Copy link

foo() will always return 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment