Le 26/12/2013 05:00, Rick Waldron a écrit :

On Wed, Dec 25, 2013 at 7:33 PM, David Bruant

    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.


The array-like part is for all of those objects that _won't_ have an @@iterator, for one reason or another
I must have missed these reasons. No @@iterator also means these objects cannot be iterated with via for-of loops by default and I can't think of a good reason for that for any of the listed (arguments, NodeList, arrays from different windows, typed arrays). Do you have a link to previous discussions on this topic or a summary if that can be explained quickly?

and for useful shimming in ES5 runtimes.
Even if Array.from relies on @@iterator for runtimes with symbols, it doesn't prevent runtimes without symbols to embed the iterator logic in the Array.from source (which is exactly what your prolyfill does).

David
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to