Hi,

I was reading the current spec for Array.from and it felt too complicated to me. Currently, at a high-level it reads like: 1) if the argument is iterable (@@iterable symbol), create a fresh array made of the values iterated on with the iterator 2) (step9) if the object is array-like, len = [[Get]] ('length') and from 0 to len-1, copy the values of the array-like in a fresh array to be returned.

Note that between the two parts, a good share of spec is duplicated.

For the rationale, the wiki states [1]:
"There are many array-like objects in JS (arguments objects, DOM NodeLists, arrays from separate windows, typed arrays) and no simple way to convert one of these to an instance of Array in the current window; this is the rationale behind a simple conversion function (Array.from)."

I think that if all of these objects had a good default @@iterable, there wouldn't be a need for the array-like part of Array.from.
The "good default" most likely being based on .length, etc.

David

[1] http://wiki.ecmascript.org/doku.php?id=strawman:array_extras
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to