Why doesn't Array.from() pass the array to the mapFn?
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
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss