0
Why I got undefiend value??
var obj={ namee:'aniket', full:`my name is ${this.namee}` } console.log(obj.full)
1 Antwort
+ 3
Getting another variable is a functional job.
Object key:value can't perform functional return.
You need to create function to call.
var obj={
namee:'aniket',
full: function() {
return `my name is ${this.namee}`;
}
}
console.log(obj.full());
Or use getter to get a function call return value.
var obj={
namee:'aniket',
get full() {
return `my name is ${this.namee}`;
}
}
console.log(obj.full);
https://code.sololearn.com/ch5FdbgSmK2O/?ref=app