javascript hoisting

var declaration

hoisted to the top of scope, without assignment.

 var a = 1;
 function printA() {
     console.log(a);
     var a = 2;
     console.log(a);
 }
 printA();
 //undefined
 //2