I have example class:
class Something{
constructor(x, y){
this.x = x;
this.y = y;
}
//...
}
如果我创建一个类继承于这个类:
class Dog extends Something{
constructor(name){
this.name = name;
}
//...
}
Dog的构造函数会长成这样吗?
constructor(x, y, name){
this.x = x;
this.y = y;
this.name = name;
}
如果不行的话,能否使它像这样^一样工作?
super(x, y);
显式地创建它。 - Andreysuper
。 - loganfsmyth