function inheritPrototype(subType,superType){
var prototype = object(superType.prototype);
prototype.constructor = subType;
//将原型指向sub对象
subType.prototype = prototype;
}
function object(o){
//创建一个空的构造函数
function F(){};
//空构造函数的原型对象指向o这个对象
F.prototype = o;
return new F();
}
//父类
function Father(){
this.name = 'zhang';
this.color = ['red','green'];
}
Father.prototype.sayName = function({console.log(this.name)}
//子类
function Son(){
//call 借用父类构造函数
Father.call(this);//自动执行改变this指向
this.age=18;
}
inheritPrototype(Son,Father);
var son = new Son();
console.log(son.color);