Argument unpacking?

P T Withington ptw at
Sat Nov 11 17:08:36 PST 2006

On 2006-11-10, at 15:21 EST, Johan Sundström wrote:


> On 11/10/06, P T Withington <ptw at> wrote:
>> My example was poor.  Replace `rest` with `[some, more, arguments]`.
>> What I'd like to say:
>>    foo.apply(bar, bletch, crud, [some, more, arguments])
> Imagine you wanted to pass the literal argument array ["bletch",
> "crud", ["some", "more", "arguments"]] (yes, the third argument being
> an array) to a which takes three arguments. It could of course
> still be done, by way of either of these syntaxes:
>   foo.apply(bar, "bletch", "crud", ["some", "more", "arguments"], []);
>   foo.apply(bar, "bletch", "crud", [["some", "more", "arguments"]]);

Then I would not use `apply`.  I would use `call`., "bletch", "crud", ["some", "more", "arguments"]);

This is exactly the difference between `call` and `apply`.  `apply`  
takes an Array and 'spreads' the arguments out to `call`.  All I was  
asking is to amend `apply` to allow you to specify additional spread  
arguments before the Array.

More information about the Es4-discuss mailing list