I have a class B which implements another class A.
In the class A I need to use variables defined in class B
class classA {
methodA() {
console.log(parentClass.variableToRetrieve);
}
}
class classB {
constructor() {
this.variableToRetrieve = 1;
this.A = new classA();
}
}
var B = new classB();
B.A.methodA();
Whats should I use in classA.methodA ans see 1 in the console ?
Edit
I already thougth to pass the B object in the classA constructor, or pass values, but as I can have hundreds variables and (potentially) millions classA, it will overload the server quickly
classBdoesn't implementclassAit just has a variable that is an instance ofclassA.this.A = new classA(this.variableToRetrieve);