function SuperType(){
this.property = true;
}
SuperType.prototype.getSuperValue = function() {
return this.property;
}
//继承
SubType.prototype = new SuperType();
SuperType.prototype = new SubType();
function SubType() {
this.subproperty = false;
}
SuperType.prototype = new SubType();
SubType.prototype.getSubValue = function() {
return this.subproperty;
}
var o = new SubType();
console.log(o.getSubValue());
console.log(o.getSuperValue());
var a = new SuperType();
console.log(a.getSubValue());
console.log(a.getSuperValue());
原型链
最新推荐文章于 2024-04-16 16:16:48 发布