The below function outputs undefined.
var x = 100;
function test() {
if(false){
var x = 130;
}
console.log(x);
}
test();
I was with the perception that, since the statement inside IF block is not executed X should display 100 since X value is declared globally.
If I comment the IF block then the global X value is taken.
Could someone explain the reason behind this.