Should I be able to apply `new`?

P T Withington ptw at pobox.com
Fri Apr 6 05:27:49 PDT 2007


Suppose I have a function that wants to be able to construct  
arbitrary objects and manipulate them:

function maker () {
   var o = new arguments[0].apply(?, arguments.slice(1));
   ...
   return o;
}

The syntax does not allow for this.  Should it?

Or should I have to use some more complicated way to apply a  
constructor to arguments?  Can I apply a class to call its constructor?

function maker () {
   var o = new arguments[0];
   arguments[0].apply(o, arguments.slice(1));
   ...
   return o;
}





More information about the Es4-discuss mailing list