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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -