Last active
August 29, 2015 13:57
-
-
Save mazuhl/9366311 to your computer and use it in GitHub Desktop.
Javascript - modified scoping example from p. 36 of Javascript: The Good Parts
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 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