var obj = {count: 0}
obj.increment = () => { this.count = this.count +1}
obj.increment()
console.log(obj.count)// outputs "error: Uncaught TypeError: Cannot read property 'count' of undefined"
But
var obj = {count: 0}
obj.increment = function() { this.count = this.count +1}
obj.increment()
console.log(obj.count) //outputs correct count
Why does the arrow function not get reference of this as the object?