Subj : Re: Using 'apply' to construct an object To : netscape.public.mozilla.jseng From : Brendan Eich Date : Tue Aug 30 2005 01:07 pm franck wrote: > In fact, I want to create an object ( new myClass... ) with a variable > argument list ( ...apply( xxx, myListOfArguments ) ) > > An alternative way to achieve this is : > > new myClass( args[0], args[1], args[2], args[3], args[4], ... args[n] ); > > But the constructor of the object I am trying to create failed if I > provide more than the expected number of arguments. > > myClass is a native JSClass class ( wxDialog(Parent, Id, Title [, > Position, Size, Style]) ) You are quite right that it's not possible to combine new with apply, unfortunately. We hit this working on Narcissus (http://lxr.mozilla.org/mozilla/source/js/narcissus/jsexec.js -- look for __construct__). This is something to work around for now, as you propose and as we did for Narcissus. We'll fix it for Edition 4 / JS2. /be .