Uninteresting parameters

Dominic Cooney dominicc at google.com
Mon Sep 26 15:22:12 PDT 2011


Since, as I understand it, these are evaluated as successive assignment to
the successive lvalues the author could adopt a practice like repeatedly
assigning to the variable _.

I am not sure that will work in const statements, though.

Dominic

On Tue, Sep 27, 2011 at 6:47 AM, Xavier MONTILLET
<xavierm02.net at gmail.com>wrote:

> 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
>
> _______________________________________________
> 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/20110927/0926df0e/attachment.html>


More information about the es-discuss mailing list