javascript - Why is the variable inside this function global? -
i thought variable defined in function local can access variable 'e' outside of function.
function change() { var d = 6; e = 7; } change(); alert(e); //> alerts 7
because new variables enter global scope default. var prevents happening constraining variable's existence within current scope.
Comments
Post a Comment