Code snippets that use .map() should be used with .forEach() instead. . map() returns a new array - always - and if we don't need that array, we shouldn't use it in the first place. In this particular example there are only three items in the array so creating another three-element array won't bring any serious consequences.

4m read timeFrom dev.to
Post cover image
Table of contents
What is wrong with .map() ?Consequences of abusing .map()Summary
11 Comments

Sort: