I have an array of object instances with different types.
var instances: any = [];
instances["Object1"] = new TypeA();
instances["ObjectB"] = new TypeB();
Each type have own methods with different names and number of arguments. I want to call this methods by calling one function and passing to it data to identify the method to call and necessary argument values(I send this data from client).
function CallMethod(data){
let args = data.args;// it's array
instances[data.objectId][data.methodId](??????);
}
Is it possible to automatic decompose args
array to pass his values as different function arguments?
Like this:
instances[data.objectId][data.methodId](args[0], args[1], ... args[n]);