0
Good afternoon, I have a question about this
and Arrow Function. For example:
const user = {
age: 32,
halfAge(){
return this.age/2;
},
doubleAge: () => 2 * this.age;
}
console.log(user.halfAge());
console.log(user.doubleAge());
Why on the console will be printed 16 and Nan? The this
is variable, and when we use a Arrow Function, the this
will no longer be variable and will point to the lexical context where is it? Failing to point to the global scope? or window in the browser.