請(qǐng)解釋代碼段注釋的this指向?代碼段鏈接出處:https://developer.mozilla.org...function Counter() { this.sum = 0; this.count = 0;
}
Counter.prototype.add = function(array) {
array.forEach(function(entry) { this.sum += entry;
++this.count;
}, this);//**該行的this是指向什么??**};var obj = new Counter();
obj.add([2, 5, 9]);
obj.count// 3 obj.sum// 16
forEach()的this指向問(wèn)題
RISEBY
2018-09-04 09:09:49
