【发布时间】:2010-10-08 07:57:16
【问题描述】:
如果被覆盖,是否可以从 JavaScript 中的原型方法调用基方法?
MyClass = function(name){
this.name = name;
this.do = function() {
//do somthing
}
};
MyClass.prototype.do = function() {
if (this.name === 'something') {
//do something new
} else {
//CALL BASE METHOD
}
};
【问题讨论】:
-
基本方法是什么? this.do = function(){} 在构造函数中?
标签: javascript prototype overriding