The scope of variable declared use 'var' is within the function(including the subfunction which can access its closure)
var my=function(){ function inner(){ console.log(a);//a is declared in the closure var b=1; } if (1<2){ var a=1; } inner(); //console.log(b);//no b in the scope } my();