Why doesn't Array.from() pass the array to the mapFn?
the kojoman
kojoman at gmail.com
Wed May 3 10:50:27 UTC 2017
Array.map(mapFn) calls the mapFn(v,i,a) passing the currentValue,
currentIndex and the array it is iterating over as arguments.
I was happy to find out about Array.from(itterable, mapFn, thisArg), but
unfortunately, the mapping didn't work as expected.
It seems, Array.from doesn't pass in the newly created array to the mapFn.
Why is that?
For instance I was expecting Array.from("aabc", (v,i,a) => { if(a[i] ===
a[i-1]) a.splice(i,1) }) to evaluate to ["a","b","c"], but a is undefined.
Is there a reason why the mapFn isn't called the same way as an Array.map
function is?
-John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170503/fb6b25b1/attachment.html>
More information about the es-discuss
mailing list