Arrays are super useful and widely used data structures. It also has a ton of different functions which can make our work so much easier. The functions that many people get confused about is map()
and forEach()
and it's reasonable both do almost the same thing. I personally made this mistake so many times when I was a beginner. The similarity is- that they both run a function or a piece of code for each of the element of the array. But forEach()
does not return any new array. It just runs the code for the elements. map()
on the other hand returns a new array with the result. Hope this helped.
Thanks for reading.
Top comments (2)
Hey great reading! Checkout also mine post about i18n libraries for ⚛️
dev.to/jpomykala/top-12-libraries-...
Thanks! Will sure check it out.