Is it possible to execute code upon inheriting a parent class? Removing the need to initialize the child class.
After fiddling around myself, and doing a week of searches, i came up empty.
// This works, its will add the class in the registry array
let registry = [];
class Parent {
constructor() {
registry.push(this)
}
}
class Child extends Parent {
}
let child = new Child();
// What i wish i could do, note that the final line of code is removed.
// Removing the line stops the program from adding the class to the array,
// is it possible to achieve the same result as above without that line?
let registry = [];
class Parent {
constructor() {
registry.push(this)
}
}
class Child extends Parent {
}