阅读背景:

javascript继承的六大模式小结

来源:互联网 

!--NEWSZW_HZH_BEGIN--

1.原型链

function SuperType(){
this.property = true;
}

SuperType.prototype.getSuperValue = function(){
return this.property;
};
function SubType(){
this.subproperty = false;
}
//继承了SuperType
SubType.prototype = new SuperType();
SubType.prototype.getSubValue = function (){
return this.subproperty;
};
var instance = new SubType();
alert(instance.getSuperValue()); //true


function SuperType()




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: