Consider the following code
Class.prototype.init = function() {
var self = this;
var onComplete = function() {
self.a.doSomethingElse(self._go);
};
console.log(this); //prints Object {...}
this.a.doSomething(onComplete); //onComplete is called inside a
};
Controller.prototype._go = function(map) {
console.log(this); //prints 'Window'
};
The question is why this
is equal to window
inside _go
function?