JavaScript question detail
How do you call the constructor of a parent class
You can use the super keyword to call the constructor of a parent class. Remember that super() must be called before using this reference. Otherwise it will cause a reference error. Let's the usage of it,
class Square extends Rectangle {
constructor(length) {
super(length, length);
this.name = "Square";
}
get area() {
return this.width * this.height;
}
set area(value) {
this.area = value;
}
}