I have two classes A
and B
, when B
extends A
. See the following code
class A {
constructor() {
this.dataProxy = 1
}
get data() {
return this.dataProxy
}
}
class B extends A {
constructor() {
super()
}
set data(value) {
this.dataProxy = value
}
}
const classB = new B()
classB.data = 7
console.log(classB.data)
Currently undefined
is output to the console, but I want to output 7
. Is there any way to do this?