I've got this code:
class Plant {
constructor({name = 'General Plant', height = 0, depth = 1, age = 0}) {
this.name = name;
this.stats = {
height: height,
depth: depth,
age: age
};
}
}
class Bush extends Plant {
constructor({name = 'General Bush', height = 2, depth = 2}) {
super(arguments)
}
}
But calling myBush = new Bush({})
results in an object with the name "General Plant" instead of "General Bush". Is there any way to set the default values in the subclass without having to manually call this.name = name
in the constructor?