Set to Array conversions

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

>> On Mon, Sep 16, 2013 at 11:33 AM, Angus Croll <anguscroll at>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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list