题解 | #类继承#

类继承

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技术

全部评论

相关推荐

10-20 16:50
门头沟学院 Java
强大的马里奥:考研报名还没结束,建议考个中游211,这样会好找一些
点赞 评论 收藏
分享
评论
2
2
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务