filter() and map() vs. forEach()
dannohh

dannohh @dannohh

Joined:
Jul 2, 2020

filter() and map() vs. forEach()

Publish Date: Jul 20 '20
2 0

What are some of the advantages of using map() and filter() vs. using forEach() methods?

Firstly, the forEach() array method always returns a value of undefined. This might be good for some scenarios, but not all. It also mutates our original array, discarding the return values.

To Be Clear~

forEach() MUTATES the current array!

VS. map() and filter()

map() and filter() methods both return new arrays that we can work with, without affecting the original array! Sweet! New Toys 👍 🎅

Comments 0 total

    Add comment