Final iterator spec

Allen Wirfs-Brock allen at
Mon Mar 3 10:08:51 PST 2014

On Mar 3, 2014, at 5:36 AM, Claude Pache wrote:

> Le 3 mars 2014 à 13:56, Andy Wingo <wingo at> a écrit :
>> On Mon 03 Mar 2014 12:49, Claude Pache <claude.pache at> writes:
>>> Le 3 mars 2014 à 10:46, Andy Wingo <wingo at> a écrit :
>>>> An iterable is simply an object with a callable @@iterator property.
>>>> Calling @@iterator on an object and getting back a result is the
>>>> sum-total of the iterator structural type -- so yes, this problem is
>>>> solved.
>>> What does exactly the spec think what an iterable is?
>> For what purpose?
> For the purpose of giving the most reasonable answer to the `if (OBJ is Iterable)` test that Caitlin Potter was asking for earlier in this thread. 
> For me, the answer should be the same as what makes `Array.from` choose between the branch "iterable" and the branch "array-like". Which, as I have said, I cannot guess until bug 2486 is resolved. Deeper philosophical thoughts over what an iterable *really* is don't matt

7.4.2	IsIterable ( obj )
The abstract operation IsIterable with argument obj performs the following steps:

1.	If Type(obj) is not Object, then return undefined.
2.	Let iteratorGetter be Get(obj, @@Iterator).
3.	Return iteratorGetter.

the above is the test that Array.from uses

An Iterable is an object that has a Symbol.iterator keyed property whose value is not undefined.  

A well-fromed Iterable is one whose @@iterator method is a function that returns an object that supports the Iterator interface. If an iterable is not well-formed then using it as such is likely to result in runtime exceptions or buggy behavior. 


More information about the es-discuss mailing list