Does anyone know why the function without the arrow is showing the name value, but if use arrow function is showing the message undefined ?
Without the arrow function:
const test = {
prop: 42,
name: "Leo",
func: function(){
return this.name
},
};
console.log(test.func());
With the arrow function:
const test = {
prop: 42,
name: "Leo",
func: function() => this.name,
};
console.log(test.func());
Here is showing the message: undefined