I am new to TypeScript and currently learning about Classes. I have a question regarding extending parent classes:
When we use the extends keyword to inherit from a parent class, we are required to call the super() method in the child class constructor. However, what if I want to skip the parent constructor or override it?
class Base {
name: string;
constructor() {
name = 'based'
console.log("Do not display this");
}
}
class Derived extends Base {
name = "derived";
constructor(){
super()
console.log("My name is " + this.name);
}
}
const d = new Derived();
[LOG]: "Do not display this"
[LOG]: "My name is derived"