1
function inherit(son,father){
son.prototype = Object.create(father.prototype);
son.prototype.constructor = son;
son.prototype.uber = father.prototype;
}
2
var inherit2 = (function () {
var temp = function () {}
return function(son,father){
temp.prototype = father.prototype;
son.prototype = new temp();
son.prototype.constructor=son;
son.prototype.uber=father.prototye;
}
}())
上面是圣杯模式常见的两种写法,当然还有其他的写法,不过要理解圣杯模式需要对原型链有深入的理解,可以参考下面的文档
你不得不知道的原型和原型链