Can I use apply() with constructor to pass arbitrary number of parameters
I've got a function wich can accept a varible number of parameter with a rest operator. I want create an object passing the argument collected with the rest operator directly to a constructor without create an object and call an initializing function and without passing the entire array but the parameters ah I do with apply() function. Is it possible ? Using apply doesn't work. public function myFunc(...arg) { // something link "new MyClass.apply(args)" return new MyClass(); } Unfortunately no. There is no way to make apply work for constructor. What is done generally is to prepare a number of