I would like to know if it is possible to extend a javascript function without having to repeat the parameters, as if it were a constructor,
function DefaultRun(args1,args2) {
}
function Run(args1, args2){
DefaultRun.call(this,
args1,
args2);
}
Run.prototype = Object.create(DefaultRun.prototype);
Would you have any way to do this?
function DefaultRun(args1, args2, args3) {
}
function Run(){
DefaultRun.call(this);
}
Run.prototype = Object.create(DefaultRun.prototype);
That is, adding an argument in the parent always needs to add in all of your children. Is it possible?
Edit ----
I need this, because I use this function in several files that have a controller in angularjs, in this style:
function Run(){
DefaultRun.call(this, ...arguments);
}
Run.prototype = Object.create(DefaultRun.prototype);
angular.module("APP").run(Run);
However, for example to use $scope
, I need to set this in the Run function, that is, if I need to add some parameters, I will need to add in all the files that use it as Father.