DEV Community

Discussion on: Useful JS functions you aren't using: Array.map

Collapse
 
zakius profile image
zakius

I always find explicit for (or at least foreach) much are readable than all the different syntaxes of map appearing in different languages. Often It's better to explicitly write line or two more than to use fancy shorthands, especially if the codebase might get visited by juniors

Collapse
 
revent profile image
Roberts Guļāns

its more apis to learn (map, find, some, every, filter, reduce) than just for-loop, but one you have done that and know where and why which function to use, value is huge.

Code speaks to you and just by reading one word you know intent what is supposed to happen. for-loop lacks such expressiveness, one have to dig into for-loop's body to understand why loop exists, what is doing.

And immutability on its own makes code so much easier to understand.

Fact that juniors also works on a project shouldn't sacrifice projects quality

Collapse
 
maxart2501 profile image
Massimo Artizzu

On the contrary, juniors should get to know the FP side of languages like JavaScript as soon as possible. And the concepts behind it, like purity and immutability.