class Stack {
lols = [];
addLol(lol) {
this.lols.push(lol);
}
}
const stack = new Stack();
abstract class BaseLol {
constructor(...prop) {
stack.addLol(this);
this.init(...prop);
console.log(stack); //Stack { lols: [ Lol { prop: 'qwe' } ] }
}
abstract init(...prop);
}
class Lol extends BaseLol {
prop;
init(prop) {
console.log(prop); //qwe
this.prop = prop;
}
}
new Lol("qwe");
console.log(stack); //Stack { lols: [ Lol { prop: undefined } ] }