DEV Community

Discussion on: Why do we write JavaScript like this?

Collapse
 
anders profile image
Anders

The article posts a question "why", and I think there has been quite a few potential answers to that question.

Not sure where you see many issues with loops though, care to elaborate with examples? =)

Collapse
 
_hhandoko profile image
Herdy Handoko

Missed the reply notification 😬

Not so much of a problem, but rather that for loops carry higher cognitive overload, whereas map or filter is composable and easier to comprehend (e.g. treating it as data pipeline).

So there is definitely a tradeoff, readability vs performance.