题解 | #继承#

继承

https://www.nowcoder.com/practice/ee1e5ee81b1c4fbb8c05a4e903621762

 <script type="text/javascript">
            function Human(name) {
                this.name = name
                this.kingdom = 'animal'
                this.color = ['yellow', 'white', 'brown', 'black']
            }
             Human.prototype.getName = function() {
				return this.name
			}
            
            function Chinese(name,age) {
                Human.call(this,name)
                this.age = age
                this.color = 'yellow'
            }

            // 补全代码
            
			// 2.继承
			Chinese.prototype = new Human()
            Chinese.prototype.constructor=Chinese

			Chinese.prototype.getAge = function() {
				return this.age
			}
        </script>函数继承
全部评论

相关推荐

用微笑面对困难:这里面最强的是驾驶证了,可以入职美团大厂,然后直接开启黄马褂人生
点赞 评论 收藏
分享
头像
08-05 15:59
已编辑
门头沟学院 运维工程师
哈哈哈,你是老六:感觉这女的就是把你当免费的劳动力
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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