I have got a base class and a derived one, each has init function.
When i construct the derived one i want it to:
call its base constructor which:
1.1. calls its init function
call its own(derived) init function.
The problem is that the derived init function is called twice.
Code:
class Base{
constructor() {
this.init();
}
init(){
console.log("Base init");
}
}
class Derived extends Base{
constructor() {
super();
this.init();
}
init(){
console.log("Derived init");
}
}
var obj = new Derived ();
Output:
Derived init
Derived init