let user = {
firstName: "John",
sayHi: () => alert(this.firstName)
};
let user2 = {
firstName : "Mike",
testFun : function(){let argFun = user.sayHi; argFun();} // Hello, undefined!
};
I understand that if I had invoked user.sayHi it would have received the value of this from the environment user was created in. But if I copy the value of user.sayHi to argFun, why doesn't this problem disappear, and isn't the code just equivalent to:
...
let user2 = {
firstName : "Mike",
testFun : function(){let argFun = () => alert(this.firstName); argFun();} // Hello, undefined!
};