Argument unpacking?

P T Withington ptw at pobox.com
Fri Nov 10 05:30:57 PST 2006


On 2006-11-09, at 17:45 EST, @lnicodon wrote:

> The thing I most miss about apply is that I cannot have 'spread args':
>>
>> foo.apply(bar, bletch, crud, rest) === foo.apply(bar, [bletch,
>> crud].concat(rest))
>
>
> Is
>
> foo.call(bar, bletch, crud, rest)
>
> an answer, or did I miss the point ?

My example was poor.  Replace `rest` with `[some, more, arguments]`.

What I'd like to say:

   foo.apply(bar, bletch, crud, [some, more, arguments])

What I have to say now:

   foo.apply(bar, [bletch,crud].concat([some, more, arguments]))

I.e., I wish apply took any number of arguments, where the last  
argument was an array that would be 'spread' into the call:

   foo.call(bar, bletch, crud, some, more, arguments)





More information about the Es4-discuss mailing list