The problem is that I need to create a new instance of the passed class
Is there a way to rewrite this function so that it can accept any number of arguments?
function createInstance(ofClass, arg1, arg2, arg3, ..., argN){ return new ofClass(arg1, arg2, arg3, ..., argN); }
This function should create an instance of a past class. Example:
var SomeClass = function(arg1, arg2, arg3){ this.someAttr = arg3; ..... } SomeClass.prototype.method = function(){} var instance = createInstance(SomeClass, 'arg1', 'arg2', 'arg3');
So that must be true.
instance instanceof SomeClass == true
Right now, I have limited N to 25, hoping that more arguments are rarely used.
user42507
source share