for-of loop

Alexander Jones alex at weej.com
Sat Aug 22 15:42:08 UTC 2015


Arrays are not iterators - they have no `next` method. '`for-of` works on
iterables.

On Saturday, August 22, 2015, Mark Volkmann <r.mark.volkmann at gmail.com>
wrote:

> I understand Arrays in ES 2015 are both iterable (have Symbol.iterator
> method) and iterators (have next method). Suppose I create a custom object
> foo that is iterable, but not an iterator because the Symbol.iterator
> method returns a different object bar. According to the spec, should I be
> able to use either foo or bar after "of" in a for-of loop?
>
> ---
> R. Mark Volkmann
> Object Computing, Inc.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org <javascript:;>
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150822/5267613c/attachment.html>


More information about the es-discuss mailing list