function BaseClass(sColor) {
this.color = sColor;
this.sayColor = function () {
alert(this.color);
};
}
function SubClass(sColor, sName) {
this.newMethod = BaseClass;
this.newMethod(sColor);
delete this.newMethod;
this.name = sName;
this.sayName = function () {
alert(this.name);
};
}
var objA = new BaseClass("red");
var objB = new SubClass("blue", "MyName");
objA.sayColor();
objB.sayColor();
objB.sayName();
|