fgerschau / comments

1 stars 0 forks source link

foreach-vs-map-javascript/ #8

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

forEach() vs. map() — JavaScript Array Function Comparison

This article does a quick comparison of the two JavaScript functions. After reading this, you should know when to use which function and why.

https://felixgerschau.com/foreach-vs-map-javascript/?fbclid=IwAR2ujIiZnX52U7RfkgMKEhG35ys5fygGjvVPxGuBSZQt817RARzNi1GCGW0

abashkin commented 3 years ago

it looks like you have mix up the map and forEach In fact it is map that does not mutates the original array and returns new one https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

fgerschau commented 3 years ago

@abashkin thanks for pointing that out, you are so right. I don't know what I was thinking while writing the article 😂

I've just pushed an update.