Possible Duplicate:
Use of .apply() with 'new' operator. Is this possible?
How to construct JavaScript object (using 'apply')?
Let's say I have a function like this one:
var Foo = function(param1, param2, param3, param4) {
...
}
I understand it is equivalent to call it in these two ways:
Foo(a, b, c, d)
Foo.apply(this, [a, b, c, d])
Let's say now I use the function to create an object:
var myObject = new Foo(a, b, c, d);
If I already have the arguments in an array [a, b, c, d], how can I call the function with the new operator an also pass the parameters with the array, like I did with apply above?
Consider I cannot modify the definition of Foo, and I don't wan't to explicitly extract the parameters a, b, c, d from [a, b, c, d]
Thanks!