Hoisting of Variables

by NesterOne

JavaScript

var a = 'a';
alert(a); //-> 'a'
function test(){
  alert(a); //-> undefined
  if(a){
      var a = 'b';
  }
  alert(a);//-> undefined
}
test();