JavaScript原型继承之圣杯模式
var inherit = (function(){
var F = function (){};
return function(Target,Origin){
F.prototype = Origin.prototype;
Target.prototype = new F();
Target.prototype.constructor = Target;
Target.prototype.uber = Origin;
}
}())
var People = function(name,age){
this.name = name;
this.age = age;
}
People.prototype.faceColor = function(color){
console.log(color)
}
var Person = function(){
}
inherit(Person,People);
// console.log(Person.faceColor('yellow'),Person.name)
// Person.prototype.faceColor('yellow')
var per = new Person();
per.faceColor('red');
inherit函数运用了函数式变成的思想