// 构造函数/基类
function Human(name){
this.name = name;
}
//将基类的方法保存在构造函数的prototype属性中
//便于子类的继承
Human.prototype.say=function(){
console.log('say');
}
//道格拉斯的object方法(等同于object.create方法)
function object(o){
var F = function(){};
F.prototype = o;
return new F();
}
//子类构造器
function Man(name,age){
//调用父类的构造函数
Human.call(this,name);
//自己属性的age
this.age = age;
}
//继承父类的方法 constructor 属性返回对创建此对象的数组函数的引用。
Man.prototype = object(Human,prototype);
Man.prototype.constructor = Man;
//实例化子类
var man = new Man("Lee", 22);
console.log(man);
//调用父类的say方法;
man.say();