Skip to content

Instantly share code, notes, and snippets.

@mazuhl
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazuhl/9366311 to your computer and use it in GitHub Desktop.
Save mazuhl/9366311 to your computer and use it in GitHub Desktop.
Javascript - modified scoping example from p. 36 of Javascript: The Good Parts
var foo = function() {
var a = 3, b = 5;
console.log("a: " + a + ", b: " + b);
if (typeof c === "undefined") { console.log("c is undefined"); }
console.log("---");
var bar = function() {
var b = 7, c = 11;
console.log("a: " + a + ", b: " + b + ", c:" + c);
console.log("---");
a += b + c;
console.log("a: " + a + ", b: " + b + ", c:" + c);
console.log("---");
};
bar();
console.log("a: " + a + ", b: " + b);
if (typeof c === "undefined") { console.log("c is undefined"); }
};
foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment