Uninteresting parameters

Xavier MONTILLET xavierm02.net at gmail.com
Mon Sep 26 14:47:02 PDT 2011


Normally, you use an object for optional arguments.

And there is no good reason not to since you don't care about the order of
the arguments.

Sent from my smartphone.
On Sep 26, 2011 11:35 PM, "Sean Eagan" <seaneagan1 at gmail.com> wrote:
> Most aspects of destructuring are supported in parameter lists:
>
> * rest parameters
> * destructuring of individual parameters
>
> However, there is at least one aspect which is not, which is
> uninteresting parameters :
>
> [x, , z] = arr;
>
> which for parameter lists would look like:
>
> function(x, , z) {...}
>
> This could be useful when you are a defining a callback which needs to
> match a certain signature, but you only care about a certain subset of
> the arguments not at the beginning. For example:
>
> function evens(arr) {
> arr.filter(function(,index) {return index % 2});
> }
>
> However, I admit it can look strange especially when the uninteresting
> parameter is at the beginning as in the above example.
>
> Thanks,
> Sean Eagan
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110926/49a79261/attachment.html>


More information about the es-discuss mailing list