我已经google了一段时间了,似乎不可能,所以我最后一次机会在这里问:是否有可能有一个函数继承自具有同名函数的原型的函数? / p>
例如在C#中,这将是这样的:
public class StupidExample {
public virtual test(){
//I do crazy stuff in here
}
}
public class Test:StupidExample {
public override test(){
base.test();
//after I did crazy stuff, I go on doing normal stuff
}
}
编辑: 我忘了提到我更喜欢使用普通的Javascript或JQuery没有像mootools这样的进一步框架
编辑:如何查找链接继承?
MyOriginBase = function() {
};
MyOriginBase.prototype.MySuperFunction = function (arg1) {
alert("Origin" + arg1);
};
MyBase = function() {
MyOriginBase.call(this);
this.m_Stuff = 0; // etc
};
MyBase.prototype.MySuperFunction = function (arg1) {
MyOriginBase.prototype.MySuperFunction.call(this, arg1);
alert("Base" + arg1);
};
MyBase.prototype = new MyOriginBase(); // innherit
MyChild = function () {
MyBase.call(this);
this.m_OtherStuff = 1; // etc
};
MyChild.prototype = new MyBase(); // innherit
MyChild.prototype.MySuperFunction = function (arg1, arg2) {
MyBase.prototype.MySuperFunction.call(this, arg1);
alert("Sub bro" + arg2);
};
var m = new MyChild();
m.MySuperFunction("34534","grtg");
不工作......