考虑以下代码
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'
};
问题是为什么this
等于window
内部_go
函数?