For-of ("for (x of iterable) {}") is a part of ES6 [1].
For-of has been shipping in Firefox since version 27 (February 2014)
[2]. IE and Safari developers have both shown willingness to implement
this part of the new language standard.
V8 has had for-of since June 2013, under the --harmony-iteration flag.
It was recently changed to perform GetIterator [3] on the iterable, in
conformance with the draft standard.
At the same time, we are looking to ship standard @@iterator methods for
arrays [4] and strings [5], so that one can iterate over arrays and
strings natively:
for (var x of [1,2,3]) console.log(x);
These @@iterator implementations make use of the new ES6 symbol facility
(also shipping in M38).
V8's for-of implementation is complete with respect to the current draft
standard, except for the late spec addition that causes for-of to "shut
down" the iterator on early exit (via break or throw) [6]. We don't
anticipate problems adding this functionality later, as it relies on the
iterator having an optional "close" method, which no iterators have
currently.
Owners: wi...@igalia.com, ross...@chromium.org
[1] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-for-in-and-for-of-statements
[2] https://developer.mozilla.org/en-US/Firefox/Releases/27#JavaScript
[3] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-getiterator
[4] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string-iterator-objects
[5] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array-iterator-objects
[6] http://esdiscuss.org/notes/2014-06-05#closing-iterators
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
Can you share a bit more about the Symbol support in Chrome 38 onwards?I want to expand the compatibility data in MDN a bit with the latest information.I understand that "Symbols" are supported. Symbol.iterator is supported and now Symbol.unscopables is also supported.What else?
Do Symbol.for and Symbol.keyFor do everything they should?
On Tue, Aug 12, 2014 at 4:03 PM, PhistucK <phis...@gmail.com> wrote:
Can you share a bit more about the Symbol support in Chrome 38 onwards?I want to expand the compatibility data in MDN a bit with the latest information.I understand that "Symbols" are supported. Symbol.iterator is supported and now Symbol.unscopables is also supported.What else?
Those two are the only traps using symbols that have been implemented.
Do Symbol.for and Symbol.keyFor do everything they should?
Yes. These should work as expected. These are useful to synchronize Symbols across globals and we use these to ensure that an iterator from one frame is iterable in another frame.
It also says Symbol.prototype.name exists only in V8 - was it removed?
It has been removed from the spec and from V8. You can still get the description by doing an explicit call to toString(). Implicit calls like + '' and String(sym) both fails.
--
erik