我试图找到一种方法在JS中调用超类的重写方法并得到了这个.
function A() {
this.superclass = new Array(A.prototype);
}
A.prototype.call_method = function(method, args, pos) {
if (!(pos >= 0)) pos = this.superclass.length - 1;
while (!this.superclass[pos].hasOwnProperty(method)) if ((--pos) < 0) return;
if (this.superclass[pos][method]) this.superclass[pos][method].apply(this, args);
if (pos) this.call_method(method, args, pos - 1);
}
A.prototype.add = function() {
this.superclass.push(arguments.callee.caller.prototype);
}
A.prototype.test = function(a, b, c) {
alert("test of A ");
}
function B() {
A.call(this);
this.add();
}
B.prototype = new A();
B.prototype.constructor = B;
B.prototype.test1 = function(a, b, c) {
alert("test …Run Code Online (Sandbox Code Playgroud)