Javascript code:
function doSomething(v1,v2){ //blah; }
function SomeClass(callbackFunction,callbackFuncParameters(*Array*))={
this.callback = callbackFuncti
Another way now available is to use spread syntax.
this.callback(...callbackFuncParameters)
Here it is again with the full example from the OP:
function doSomething(v1,v2) {
console.log('doing', {v1, v2});
}
function SomeClass(callbackFunction, callbackFuncParameters) {
this.callback = callbackFunction;
this.method = function(){
this.callback(...callbackFuncParameters); // spread!
}
}
var obj = new SomeClass( doSomething, Array('v1text','v2text') );
obj.method()
// output: doing {v1: "v1text", v2: "v2text"}