thisArg
kullanımı
( ! ) Notice: Undefined index: description in /home/prototurk.com/public_html/app/controller/demo.php on line 171 Call Stack # Time Memory Function Location 1 0.0004 368152 {main}( ) .../index.php:0 2 0.0032 450000 require( '/home/prototurk.com/public_html/app/controller/demo.php' ) .../index.php:101
function Counter() {
this.sum = 0
this.count = 0
}
Counter.prototype.add = function(array) {
array.forEach(entry => {
this.sum += entry
++this.count
}, this)
}
const obj = new Counter()
obj.add([2, 5, 9])
console.log(obj.count)
// 3
console.log(obj.sum)
// 16