Set to Array conversions

Rick Waldron waldron.rick at gmail.com
Mon Sep 16 12:15:10 PDT 2013


>
>>
>> On Mon, Sep 16, 2013 at 11:33 AM, Angus Croll <anguscroll at gmail.com>wrote:
>>
>>> I'm trying to figure out the most painless way, given a set, to return
>>> the set's values as an array.
>>>
>>
>>
>> set.values(); // An array of the set's values
>>
>
> Whoops, that's totally wrong information. (that's what I get for rushing
> blindly into a thread!) Apologies.
>

I think I owe some clarification and an explanation of my apparent madness.
I made this mistake is because I've grown accustomed to using for-of
(FirefoxOS!) for iteration:

var s = new Set([1,2,3,4])

for (var n of s) { ... }

for (var n of s.values()) { ... }

var a = [1,2,3,4];

for (var n of a) { ... }

As you can see, there is no need to consider the data types different when
iterating their values—which is the excuse I'm going with: getting too
comfortable. Anyway, apologies again for the incorrect information; the
good news is that these new data types fit well in common patterns.

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130916/826809fe/attachment.html>


More information about the es-discuss mailing list