Last active
April 22, 2016 13:46
-
-
Save gurucharanmk/e6c1bb820129ca5328687ae17de0e22e 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
function checkVar() { | |
var validate = 1; //Make it 0 to execute else block | |
if(validate) { | |
var varName = "test"; //comment this line to confirm exception | |
console.log(varName); | |
} | |
else{ | |
console.log(varName); //varName is accessible with value undefined | |
} | |
console.log(varName); // varName is accessible and defined if validate = 1, varName is accessible but undefined if validate = 0 | |
} | |
checkVar(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment