题解 |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
        }
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-09 12:23
转人工😡
门口唉提是地铁杀:五次握手了
点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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