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: [email protected], [email protected]
[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
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.