I thought I understood the relationship between this
and arrow functions but the following snippet is making me question my understanding.
let person = {
name: 'Jim',
sayName: () => {
console.log(this.name);
}
};
person.sayName();
I understand that arrow functions capture the this
value of the enclosing context. I was expecting this
would be the object but instead it is Window
.
Can someone help me understand why this is the case?