题解 |JS18 继承

        function Human(name) {
            this.name = name
            this.kingdom = 'animal'
            this.color = ['yellow', 'white', 'brown', 'black']
        }
        
        function Chinese(name,age) {
            Human.call(this,name)
            this.age = age
            this.color = 'yellow'
        }

        // 补全代码
        Human.prototype.getName = function(){
            return this.name;
        }
        Chinese.prototype = new Human();
        Chinese.prototype.constructor = Chinese;
        Chinese.prototype.getAge = function(){
            return this.age
        }
全部评论

相关推荐

09-12 11:55
已编辑
湖南工商大学 Java
那一天的Java_J...:这种一堆问题的,别去
点赞 评论 收藏
分享
10-10 01:10
已编辑
深圳大学 测试开发
面了100年面试不知...:六月到九月,四个项目一个实习,是魔丸吗
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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