Closed mathiasbynens closed 10 years ago
http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#april_5_2014_draft_rev_23
7.4.2
IsIterable ( obj )
The abstract operation
IsIterable
with argumentobj
performs the following steps:
- If
Type(obj)
is notObject
, then returnundefined
.- Let
iteratorGetter
beGet(obj, @@Iterator)
.- Return
iteratorGetter
.
https://github.com/mathiasbynens/Array.from/blob/1e9b05dd983c575ebe12255fea522cd76113e090/array-from.js#L59 Looks like the last parameter items
should be removed as per the latest http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from.
This appears to have been cleared up - Array.from never leaves a hole. https://twitter.com/awbjs/status/496443722133798912
Array.from({ '0': 1, '2': 2, 'length': 3 })
should not return a sparse arrayDiscussed in http://esdiscuss.org/topic/array-from-and-sparse-arrays.
Array.from([1,,2])
returns a non-sparse array (because it uses the iterator case, see bug 2416), butArray.from({0: 1, 2: 2, length: 3 })
returns a sparse array (because it uses the ‘array-like’ case).It was suggested that the two cases should be made consistent. Since “holes are evil”, the array-like case should lose the
kPresent
test in step 17b etc.IsIterable
is not definedIt will be defined in the rev23. Once that happens, #4 can be fixed.