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

相关推荐

双飞鼠鼠不会梦到大厂offer:就说课很少并且导员鼓励出来实习
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务