题解 | #类继承#
类继承
https://www.nowcoder.com/practice/c06b31bf07b94c5f9dbef9645e97ea28
class Human {
constructor(name) {
this.name = name
this.kingdom = 'animal'
this.color = ['yellow', 'white', 'brown', 'black']
}
// 补全代码
getName(){
return this.name
}
}
// 补全代码 extends 继承Human类
class Chinese extends Human {
constructor(name, age) {
// 从父类集成name属性
super(name);
this.age = age;
}
getAge() {
return this.age;
}
}
在线编程题解 文章被收录于专栏
web技术
腾讯云智研发成长空间 216人发布

查看17道真题和解析