Why does Array.from accept non-iterable arraylikes?

Jason Orendorff jason.orendorff at gmail.com
Mon Jun 24 08:54:35 PDT 2013


According to [1], Array.from will first try treating the argument as
an iterable, then as an arraylike. This is much better than just
arraylike. The committee considered making it iterable only, but
decided against it. The rationale recorded in the notes is:

    RW: No.

Rick, can you expand on that a bit? :-)

I propose changing it to iterable only. All builtin arraylike objects
are iterable now, including arguments, per the same discussion.[1]
Certainly the idea is for all DOM arraylikes to be iterable. So what
is this for?

  [1]: https://github.com/rwldrn/tc39-notes/blob/master/es6/2012-11/nov-29.md#revisit-nov-27-resolution-on-iterables-in-spread

-j

P.S. Rick: Thanks again for taking notes at the meetings. They're
indispensible. I've cloned the repo; grepping the notes has been super
useful too.


More information about the es-discuss mailing list