DEV Community

Discussion on: 4 main differences between forEach() and map() you should know

Collapse
 
slowry96 profile image
Samuel Lowry

Liked the post. I think the easiest point for me to remember the difference is how I would use the two function names in a sentence. For a .map() example, "I'm going to this new land area out." This sentence implies the production of some item, a new map of a new land area. Just like the function .map(), we will have a new item mapped out after the action is done. For forEach(), "For each lemon I have, I'm going to cut it in half." Here for each implies that I'm going to perform an action on each individual lemon. Just like the function call itself.

For most function names I try to do some kind of relation to their context in a sentence.

After all, I bet there was probably a bit of though that was put into the naming of these functions by the JS architect who designed them.

😁😁

Collapse
 
ibrahima92 profile image
Ibrahima Ndaw

😂😂The way of differentiating thing is just funny. I should give it a try.