继承:
原型链继承
function SuperType() {
this.propperty = true;
}
Supertype.prototype.getSuperValue = function() {
return this.propperty;
}
function SubType() {
this.subproperty = false;
}
// 继承了SubType
SubType.prototype = new SuperType();
SubType.prototype.getSubValue = function () {
return this.subproperty;
}
var instance = new SubType();
console.log(instance.getSuperValue()); // true
时间: 2024-12-17 03:49:26