var variable = "top level " ;
function outer(){
alert(variable); // why does this alert returns undefined ??
var variable = " inside outer, outside inner";
function inner(){
alert(variable);
}
inner();
}
outer();
What I understood from the definition of lexical scoping is that, the functions can access all the values in and above their scope i.e. everything defined before them. So why does the first alert returns undefined ?