I understand 'this' in the arrow function points to this in the upper excution context.
var name = 'aaa';
const person = {
name: 'bbb',
getName: () => {return console.log(this.name)}
}
person.getName();
so I understand that getName() is logging the name of the global object in the code above.
const name = 'aaa';
const Person = function() {
this.name = 'bbb';
this.getName = () => {return console.log(this.name)}
}
const test = new Person();
test.getName();
However, the test object in this code is an object that is created as a Person constructor. Therefore, I think getName() of test object is the same as this used in method in object as above code. What did I understand wrong?