(an index in Array.from wouldn't make sense, because Array.from takes an
iterable *or* an arraylike - and only an arraylike would be guaranteed to
have an index, or even a "list" at all)

On Wed, May 3, 2017 at 11:35 AM, Jordan Harband <[email protected]> wrote:

> 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@farsightsoftware.
> com> wrote:
>
>> On Wed, May 3, 2017 at 12:39 PM, the kojoman <[email protected]> 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
>> [email protected]
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to