Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between the map methods in ES6 and lodash?

Can one do more than the other? Should I stick with lodash or just use ES6's map method?

like image 743
Funk Soul Ninja Avatar asked Nov 07 '16 19:11

Funk Soul Ninja


2 Answers

Besides @georg's comment on the possibility of using lodash _.map as a shorthand for _.property, lodash map can be used for any iteratable, whereas ES6 map can only be used for arrays.

like image 51
erikvdplas Avatar answered Nov 14 '22 22:11

erikvdplas


They're both compliant with the ECMA-262 spec, so they're identical. However, for portability (and perhaps performance/readability), I personally prefer the built-in ES6 map method.

like image 39
matanso Avatar answered Nov 14 '22 21:11

matanso