Reading Dr. Axel Rauschmayer\'s blog on ES6 classes, I understand that a derived class has the following default constructor when none is provided
constructo
You need to call super in a subclass constructor in these cases:
this in the subclass constructorIn other cases, you can call it if you want the superclass constructor to run, but you don't have to.
class SuperClass{
constructor() {
console.log('SuperClass');
}
}
class SubClass1 extends SuperClass {
constructor() {
console.log('SubClass1');
super();
return {};
}
}
class SubClass2 extends SuperClass {
constructor() {
console.log('SubClass2');
return {};
}
}
new SubClass1();
new SubClass2();
I don't see how the order of arguments matters when deciding whether you should call super or not.