Skip to content

Instantly share code, notes, and snippets.

@dvdrtrgn
Last active May 11, 2022 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvdrtrgn/8efb90d91d961eb544ee3a5226439c4f to your computer and use it in GitHub Desktop.
Save dvdrtrgn/8efb90d91d961eb544ee3a5226439c4f to your computer and use it in GitHub Desktop.
Extended Class order of inits
#!/usr/bin/env node
let C = console;
class C0 {
constructor() {
C.log(`C0 construct’d`);
C.log(`C0 this’d`, this);
}
foo = (() => C.log(`C0 init`))() || `C0 init`;
}
class C1 extends C0 {
constructor() {
C.log(`C1 construct’d`);
C.log(`C1 super’d`, super());
}
foo = (() => C.log(`C1 init`))() || `C1 init`;
}
class C2 extends C1 {
constructor() {
C.log(`C2 construct’d`);
C.log(`C2 super’d`, super());
}
foo = (() => C.log(`C2 init`))() || `C2 init`;
}
new C2();
{
"name": "class-order-of-inits",
"version": "1.0.0",
"bin": "./index.js"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment