1 //圣杯模式 2 function inherit(Target,Origin){ 3 function F(){}; 4 Target.prototype = new F(); 5 F.prototype = Origin.prototype; 6 Target.prototype.constructor = Target; 7 Target.prototype.uber = Origin.prototype; 8 } 9 10 //雅虎 YUI3 11 var inherit = (function(){ 12 var F = function(){}; 13 return function(Target,Origin){ 14 F.prototype = Origin.prototype; 15 Target.prototype = new F(); 16 Target.prototype.constructor = Target; 17 Target.prototype.uber = Origin.prototype; 18 } 19 })