I was playing aroun and found interessting thing
var x = "x";
function a (){
    var x = "y";
  if(1){
    var x = "g";
    alert(x);
  }
  alert(x)
}
a()
why does this output "g" , "g" insted of "g" , "y" ? The if creates another block scope and x is local variable inside it which means when i get out of the if block , the outer x ( which equals "y" ) should be printed.
 
    