This is my first question on Stackoverflow so please dont run over me like a bulldozer if i did something wrong :)
I need to know if its possible in JavaScript classes to know, if the child has provided a constructor.
E.g.
class Parent {
constructor() {
console.log('Child has constructor:', /* Magic here */)
}
}
class Child extends Parent {}
new Child()
Expected output: Child has constructor: false
Vs:
class Parent {
constructor() {
console.log('Child has constructor:', /* Magic here */)
}
}
class Child extends Parent {
constructor() {
super()
}
}
new Child()
Expected output: Child has constructor: true
Background: I would like to have a class that behaves differently when it was extended than if it was used directly. Since Childs should provide the Parent different informations than if it was used directly.