DEV Community

Discussion on: filter, map and reduce in JS. When and Where to use??

uuykay profile image
William Kuang

Performing map, then filter is 2 iterations of the list. Despite some small readability gains, the performance loss is just too great.

Thread Thread
lukeshiru profile image
LUKESHIRU

"performance loss is too great" ... have you actually ran the code above? Browsers optimize those kind of chained operations. The performance difference might br noticeable maybe with, idk, 100k items, but if you have to filter/map that amount of items, your problem is elsewhere.....