首页 > 其他 > 详细

面向对象组合继承

时间:2016-09-24 11:46:09      阅读:128      评论:0      收藏:0      [点我收藏+]
function Person(name,sex,age){
this.name = name;
this.sex = sex;
this.age = age;
}
Person.prototype.eat = function(){
console.log("每个人都会吃饭");
}
function Programmer(name,sex,age){
this.habby = "看书";
Person.call(this,name,sex,age)
}
Programmer.prototype = Person.prototype;
Programmer.prototype.writeCode = function(){
console.log("写代码");
}

var programmer = new Programmer("张三","男",20);
console.log(programmer);

面向对象组合继承

原文:http://www.cnblogs.com/ypengbk/p/5902614.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!