I have a piece of code, like this:
let a = { b: 3, c: this.b }
The code doesn't work and returns "undefined". How do I access property b on property c?
I have a piece of code, like this:
let a = { b: 3, c: this.b }
The code doesn't work and returns "undefined". How do I access property b on property c?
How to
get
?
=> use get
let a = {
b: 3,
get c() {
return this.b;
}
}
console.log(a.b, a.c);