Claude Pache (2014-02-24T23:12:25.000Z)
domenic at domenicdenicola.com (2014-03-02T22:43:33.608Z)
Here is an idea for easily defining an "iterator with holes", so that `Array.from` could reconstruct a sparse array from an iterable: Iterators yield IteratorResult objects, which are of the form `{done: <boolean>, value: <any>}`. The idea is to produce results of the form `{done: true}` (omitting the `value` key) in order to indicate a "hole". For consumers that don't want holes (e.g. `for/of` loops), it will be equivalent to `{done: true, value: undefined}`, but consumers that are willing to make the difference between holes and `undefined` can distinguish the two cases. For instance, successive application of the `next` method on `[1, , 2].values()` will produce the results: {done: false, value: 1} ; {done: false} ; {done: false, value: 2} ; {done true, value: undefined} whereas `[1, undefined, 2].values()` will produce {done: false, value: 1} ; {done: false, value: undefined} ; {done: false, value: 2} ; {done true, value: undefined} (Naturally, generators won't be able to produce "iterators with holes": if you really want such a silly iterable, the punishment is that you are obliged to construct it "by hand".)