Given the following object:
var myObj = {
fname: 'John',
lname: 'Doe',
values: {
get fullName() {
return this.fname + ' ' + this.lname
}
}
};
When trying to access myObj.values.fullName
, undefined undefined
is returned because the context of this
is set to myObj.values
, not myObj
.
Is there a way to change that? I tried every combination of bind
I can think of, but most of the time this just results in syntax error because fullName
isn't a regular function.