Skip to content

Instantly share code, notes, and snippets.

@gerlacdt
Created October 22, 2016 17:46
Show Gist options
  • Save gerlacdt/87098fb2440fd351f61b2a7116af81b7 to your computer and use it in GitHub Desktop.
Save gerlacdt/87098fb2440fd351f61b2a7116af81b7 to your computer and use it in GitHub Desktop.
class Bar {
constructor() {
this.foo = "foo from Bar";
}
fooFunc() {
return this.foo;
}
}
class Foo {
constructor (bar) {
this.bar = bar;
this.foo = "foo from Foo";
}
fooFunc() {
return this.foo;
}
}
const bar = new Bar();
const foo = new Foo(bar);
console.log('foo.fooFunc(): ' + foo.fooFunc()); // expected "foo from Foo"
console.log('foo.bar.fooFunc(): ' + foo.bar.fooFunc()); // expected "foo from Bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment