I was messing around with classes when I found this weird behaviour:
class A {
test = 1
}
class B extends A {
get test () {
return 2
}
}
const b = new B()
console.log(b.test)
The logical answer to the output should be 2
but when running the code, the output is 1
.
Am I missing something? Is this intended javascript behaviour? I could not find anything in the MDN documentation about this.
I found this question which might be related to mine but it did not include any work arounds.