js圣杯模式
//圣杯模式 改变子属性不会影响父对应的属性 // function inherit(Target, Origin) { // function F() { } // F.prototype = Origin.prototype // Target.prototype = new F() // Target.prototype.constructor = Target // } var inherit = (function () { var F = function () { }; return function (Target, Origin) { F.prototype = Origin.prototype Target.prototype = new F() Target.prototype.constructor = Target } }()) Father.prototype.lastName = "haha" function Father() { } function Son() { } inherit(Son, Father) var son = new Son() var father = new Father()