Created
March 28, 2018 11:29
-
-
Save aryak007/a1a781c8ddb1787b44aa2c632e93e5a6 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
// Lexical scope means compile time scope | |
var foo = "bar"; | |
function bar(){ | |
var foo = "baz"; //This is called shadowing. It will be in the local scope. | |
function baz(foo){ | |
foo = "bam"; // Gets assigned to the local foo again | |
bam = "yay"; | |
} | |
baz(); // JS variatic functions. | |
} | |
bar(); | |
console.log(foo); // bar | |
console.log(bam); //yay | |
baz(); // Undefined Reference error!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment