I have a question regarding the outer environment in JS. Suppose I have the code like this:
function callbackTest(callback) {
var a = 1;
callback();
}
callbackTest(function() {
console.log(a);
});
The brower told me that a is not defined. It means the outer environment is the global context, but I created the function within callbackTest, so I assume the outer environment of callback is the callbackTest. Can somebody tell me why? Thx!