Final iterator spec

Domenic Denicola domenic at
Sat Mar 1 19:18:36 PST 2014

You can just do `if (Symbol.iterator in potentialIterable)`.
From: Caitlin Potter<mailto:caitpotter88 at>
Sent: ‎3/‎1/‎2014 22:01
To: es-discuss at<mailto:es-discuss at>
Subject: Re: Re: Final iterator spec

I have a concern with these, which isn't 100% related to this thread, but is on the topic of iterators.

So, in Dart, we have this nice option of basically saying `if (OBJ is Iterable)`, and we'll be able to know easily if an object conforms to that particular interface.

Admittedly, this construct makes a lot more sense in Dart than it does in Javascript, but it would be nice to have some kind of helper which will determine if
an object adheres to the Iterable interface. For instance, `Object.isIterable() => true` if the interface is present in the object's prototype.

It would be nice to have a convenience function for this largely because it feels like the VM should have an easier time knowing if an object is iterable or not, and may be able to cache its knowledge of the Iterable status of an object, for performance reasons.

Maybe it would be good if a helper function like this would also determine that the return value of `@@iterator()` also conforms to the Iterator interface, or maybe that's not super important. But in any case, I could see utilities like this being very helpful.

Maybe that ship has sailed, but if something like that would hurt the harmony status of iterators, I would be interested in hearing the specific reasons against it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list