Why doesn't Array.from() pass the array to the mapFn?

Jordan Harband ljharb at gmail.com
Wed May 3 18:35:14 UTC 2017

I think what you're looking for is map + filter - mutating the list
mid-iteration is very bad news bears.

In other words, `Array.from(arrayLike, mapFn).filter(removeWhatever)`

On Wed, May 3, 2017 at 4:46 AM, T.J. Crowder <
tj.crowder at farsightsoftware.com> wrote:

> On Wed, May 3, 2017 at 12:39 PM, the kojoman <kojoman at gmail.com> wrote:
>> Thanks for the clarification. I thought the mapping was applied
>> afterwards.
>> I would still argue that it would be better to skip it all together than
>> having it and not working like the existing map function.
> So Array.from(array-like).map(mapFn) is the way to go then?
> Why make two passes over the contents rather than just one?
> It is interesting that `Array.from` doesn't pass its first parameter
> (`items`, the source object) as the third argument to the mapping function.
> I suspect it's because the index doesn't necessarily work with the source
> object, if an iterator is being used...
> -- T.J. Crowder
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170503/df9b4170/attachment-0001.html>

More information about the es-discuss mailing list