Allen Wirfs-Brock (2013-10-30T18:28:33.000Z)
domenic at domenicdenicola.com (2013-11-03T22:30:29.656Z)
On Oct 30, 2013, at 10:51 AM, Boris Zbarsky wrote: > We could change that if we change all DOM arraylikesto be iterables (which they already are, I suspect). All that is needed is to add an @@iterator method whose definition is identical to http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.values ArrayIterator objects (http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array-iterator-object-structure ) will work fine with any Array-like objects. But note that ES6 Rev20 has simplified them from what is shown at this link. > The biggest compat issue will be cases that pass `{ "length": 1, 0: "x" }` to a sequence<DOMString> or something, but do people do this in practice? Those are the sort of objects, that we decided to explicitly exclude from spread and for-of. We could wrap an ArrayIterator around any object in those contexts that didn't have a @@iterator. But that would mean that all objects would default to array-like iteration in those contexts. When we discussed this we decided it is more likely that attempting to spreading or iterating over a object without a @@iterator is indication of a program bug. So we throw on it. For something like `{ "length": 1, 0: "x" }`, one way to make it iterable would be `{ "length": 1, 0: "x" , [Symbol.iterator]: [].values}}`