Skip to content

Instantly share code, notes, and snippets.

@me-shaon
Created November 13, 2017 13:28
Show Gist options
  • Save me-shaon/28f438cd4c165acc6abff7957efdabf0 to your computer and use it in GitHub Desktop.
Save me-shaon/28f438cd4c165acc6abff7957efdabf0 to your computer and use it in GitHub Desktop.
Sample Function Scope example for Medium Article
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