Saturday, May 11, 2024
189
rated 0 times [  190] [ 1]  / answers: 1 / hits: 122493  / 11 Years ago, mon, may 6, 2013, 12:00:00

I have turned on the Chrome flag for experimental ECMAscript 6 features, one of which is Set. As I understand, the details of Set are broadly agreed upon by the spec writers.



I create a set a and add the string 'Hello'



a = Set();
a.add('Hello');


but how do I iterate over the elements of a?



for(let i of a) { console.log(i); }


gives SyntaxError: Illegal let declaration outside extended mode



for(var i of a) { console.log(i); }


gives SyntaxError: Unexpected identifier



for(var i in a) { console.log(i); }


gives Undefined



Is it possible to iterate over of a set in Chrome 26?


More From » ecmascript-6

 Answers
4

The of operator doesn't appear to be currently supported in Chrome. It seems that only FireFox versions 13 through 18 support it. It also appears that none of the browsers actually support Set although the page does say that some of the tests represent existence and not full functionality or coherence. So it might be that Set is partially implemented in Chrome.


[#78405] Saturday, May 4, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
julieth

Total Points: 382
Total Questions: 99
Total Answers: 85

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
julieth questions
;