I have a class like this:
export class Test {
#foo
#bar
constructor() {}
get foo() {
if (!this.#foo) this.#foo = 1 * 1
return this.#foo
}
get bar() {
if (!this.#bar) this.#bar = 2 * 2
return this.#bar
}
}
I need all the getters results in this class so I want to invoke all of them.
I have tried to invoke them outside the class but there are private members in the class so I get an error:
TypeError: Cannot read private member #foo from an object whose class did not declare it
I have tried to invoke them inside the constructor by looping on Object.getOwnPropertyNames(this)
but this don’t invoke the getters.
Is there a way I can invoke them inside the class so the getters can use the private members?
Thanks!