I was trying to implement mongoose virtual getter :
UserSchema.virtual('fullName')
.get(function () {
return `${this.firstName} ${this.lastName}`;
})
I have noticed that when I use es6 arrow function instead of the normal anonymous function as a parameter to the the get the virtual getter would return undefined.
I know that arrow functions keeps the context of this
but where is the this
that the normal anonymous function is using?.
if it was passed by .bind or using the call()/apply() functions then it shouldn't matter if it is arrow function or normal(that's what I tested atleast). So why is this only working with normal functions but not arrow functions?.