Hi Dustin, Well it does, apparently it was called the "splat" operator, which (to me) sounds a better than "spread". I think it works like:-
var args = [12, true]; new C(...args); function C( count, isSemiAnnual) { } - Maybe one of guys writing the specs can comment on that. It can be hacked in ES3:- /** * @param {Function} fun constructor to be invoked. * @param {Array} args arguments to pass to the constructor. * Instantiates a constructor and uses apply(). */ newApply : function(fun, args) { if(arguments.length === 0) return; var f = arguments.callee, i; f.prototype = fun.prototype;// Copy prototype. f.prototype.constructor = fun; i = new f; fun.apply(i, args); // Apply the original constructor. return i; }, - from http://dhtmlkitchen.com/ape/build/APE.js Garrett On Thu, Mar 13, 2008 at 10:48 AM, Dominic Cooney <[EMAIL PROTECTED]> wrote: > Why doesn't Function have something like apply that does the same as > in a new expression, i.e. allocate-init-and-apply? To put it another > way: given arguments in an array, I want to write: > > F.thisThing(args) and have it mean the same as new F(args[0], args[1], > ... args[n-1]) > > Or is what happens behind the veil of object creation detailed enough > that I can write a facsimile of it with apply? I guess something like: > > var x = {}; > x.prototype = F.prototype; > x = F.apply(x, args) || x; > > But why force me to guess? No doubt I am wrong. > > Dominic > > > > On Mon, Mar 10, 2008 at 7:38 PM, Jon Zeppieri <[EMAIL PROTECTED]> wrote: > > On 3/10/08, Lars Hansen <[EMAIL PROTECTED]> wrote: > > > First draft of the spec for the Function class. Please comment. > > > > > > > Suggestion: deprecate the Function constructor and static invoke(). > > > > Almost all of its uses are better handled by function expressions and, > > in those cases where eval() in required, one can use eval(). > > > > -Jon > > > > > > _______________________________________________ > > Es4-discuss mailing list > > Es4-discuss@mozilla.org > > https://mail.mozilla.org/listinfo/es4-discuss > > > _______________________________________________ > Es4-discuss mailing list > Es4-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es4-discuss > _______________________________________________ Es4-discuss mailing list Es4-discuss@mozilla.org https://mail.mozilla.org/listinfo/es4-discuss