Where not to use arrow function

1

var btn = document.querySelector('.btn');

btn.addEventListiner('click', function(){
    console.log(this); // this referes to button clicked on
});

2

var person = { points: 10, score: function(){ this.points++; } };

person.score(); // 11 person.score(); // 12 person.score(); // 13

## 3

```javascript
class Person{
    constructor(name){
        this.name = name
    }
}

var p = new Person('Hemant');

Person.prototype.sayName = function(){
    console.log('My name is ' + this.name);    
};

p.sayName(); // My name is Hemant

4

var myFun = () => {
    console.log(arguments); //     Uncaught ReferenceError: arguments is not defined
};

Last updated

Was this helpful?