//中间层 F
// Father.prototype
//
// var F = function () {}
// F.prototype = Father.prototype
// new F()
//
//Father Son = new F()
//圣杯模式
var inherit = function (Target,Origin) {
var F = function () {};
F.prototype = Origin.prototype;
Target.prototype = new F();
//完整的。。
Target.prototype.constructor = Target;//若无,则 Target.prototype.constructor --> F.prototype.constructor --> Origin.prototype.constructor
Target.prototype.uper = Origin.prototype; //即超类,uper类似super,uper以区分书写
}
//Yahoo YUIs
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.prototype;
}
}
//闭包中的私有变量
function Deng(name,wife) {
var prepareWife = "xiaozhang";
this.name = name;
this.wife = wife;
this.devorce = function () {
this.wife = prepareWife;
}
this.changePrepareWife = function (target) {
prepareWife = target;
}
this.sayPrepareWife = function () {
console.log(prepareWife);
}
}
var D = new Deng("Deng","xiaoliu");