我正在使用自私的JavaScript库来简化javascript中的继承。 例如,我有两个对象
var Foo = Base.extend({
initialize: function(){
this.some_param = 1;
}
}),
Bar = Base.extend({
initialize: function(){
this.another_param = 2;
}
});
如何从Bar初始化程序调用Foo初始化程序?
答案 0 :(得分:2)
var Foo = Base.extend({
initialize: function(){
this.some_param = 1;
}
}),
Bar = Base.extend({
initialize: function(){
Foo.initialize.call(this); // <------- here
this.another_param = 2;
}
});