Suggestions for Set

Rick Waldron waldron.rick at gmail.com
Tue Oct 2 13:52:29 PDT 2012


On Tue, Oct 2, 2012 at 4:26 PM, Erik Arvidsson <erik.arvidsson at gmail.com>wrote:

> On Mon, Oct 1, 2012 at 11:46 PM, Domenic Denicola
> <domenic at domenicdenicola.com> wrote:
> > -----Original Message-----
> > From: es-discuss-bounces at mozilla.org [mailto:
> es-discuss-bounces at mozilla.org] On Behalf Of Brendan Eich
> > Sent: Monday, October 1, 2012 21:43
> > To: Nicholas C. Zakas
> >
> >> > I would really like to see a *Set.prototype.toArray* method to easily
> change the Set back into an array. A simple use case would be de-duping an
> array:
> >> >
> >> >     function dedupe(array) {
> >> >         return (new Set(array)).toArray();
> >> >     }
> >> >
> >> >
> >>
> >> Array.from is the way we hope to avoid burdening many iterables with
> "toArray" methods, as Rick pointed out. Ok?
> >
> > Also:
> >
> > function dedupe(array) {
> >     return [...new Set(array)];
> > }
>
> I'm not sure we ended up with iteration for spread?
>
> Another alternative:
>
> function dedupe(array) {
>   return [x for x of new Set(array)];
> }
>
>
No iteration for spread, per July 24 resolution
https://mail.mozilla.org/pipermail/es-discuss/2012-July/024207.html

Rick



>
> > This works in Firefox Aurora, for the record :)
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
>
>
>
> --
> erik
> _______________________________________________
> 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/20121002/77fc4768/attachment-0001.html>


More information about the es-discuss mailing list