Created
November 13, 2017 13:28
-
-
Save me-shaon/28f438cd4c165acc6abff7957efdabf0 to your computer and use it in GitHub Desktop.
Sample Function Scope example for Medium Article
This file contains hidden or 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
function testFunction() { //Scope 1: Starts here. This scope is created by the Function block | |
var a = 1; | |
if(true) { //This block is not creating any new Scope | |
var b = 2; | |
console.log(a, b); //'a', 'b' both is accessible here | |
} | |
console.log(b); //Though 'b' defined inside the 'if' block, it's still accessible here | |
} //Scope 1: Ends here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment