related codes
var a = "aa";
test ();
function test () {
console.log (a);
var a = "bb";
console.log (a);
}
console.log (a);
/ / undefined bb aa
I would like to ask why the undefined is printed in the first place. Isn"t it possible to access variables outside the function inside the function