Set to Array conversions

Angus Croll anguscroll at
Mon Sep 16 08:33:50 PDT 2013

I'm trying to figure out the most painless way, given a set, to return the
set's values as an array.

1) harmony wiki (
suggests the following, but it is a syntax error in traceur, continuum and
"node --harmony"

let arr = [e for e of mySet];

2)The ES6 standard supports the following production (i.e. expression, not
var, before 'for'):
*IterationStatement : for ( LeftHandSideExpression of AssignmentExpression
) Statement*

which suggests I should be able to do this:
let arr = [];
for (arr[arr.length-1] of mySet);

(I can do the equivalent with for-in) but that also errors in the above
three transpilers

3) So then I'm left with the pedestrian:
let arr = [];
for (e of mySet) {

4) I also wondered if Array.from(mySet) would do the trick but again
doesn't seem to pass muster with any of the above transpilers. (continuum
 returns a zero length array and the other two don't know Array.from)

Wondering if I'm missing something better.

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

More information about the es-discuss mailing list