I have a class "Foo" which is compossed by two classes "Bar" and "Baz"
function Foo() {
this.bar = new Bar();
this.baz = new Baz();
}
-----------------------------------------
function Bar() {
this.bar = something1();
}
Bar.prototype.methodN = () => {
// some stuff with bar
}
-----------------------------------------
function Baz() {
this.baz = something2();
this.bar = new Bar();
}
Baz.prototype.method0 = () => {
// some stuff with baz
}
Baz.prototype.methodN = () => {
// some stuff with baz and bar
}
Then, if I create an instance of Foo
const foo = new Foo();
how can I call methods of Bar and Baz using foo?