forEach
Learn about `forEach` and how it allows us to quickly process data and how it differs from `map` and `filter`.
We'll cover the following
forEach
Array.forEach
is different from map
& filter
. You may find it easier to reason about. map
& filter
return us new, altered arrays based off of the original array. forEach
returns us undefined
. It’s used purely to do something with the items in an array, not to get a new array out of it.
Here’s an example. The following two code blocks are equivalent.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy