Death of the for loop

So I was hit with a revelation this morning. I haven’t written a for loop in months. Is this the end of it? Has it been replaced with functions like map, filter and find?

Functional programming ideas are definitely leaking into everyday languages. First class functions definitely are a big part of this.

Take a React example. If I have a list of items, I’ll typically end up with code such as:-

   { string) => <li key={name}>{name}</li>)}

The alternative is:-

for (let i = 0; i < names.length; i++) {
   output(`<li key="${names}">${names}</li>`);

I know which I prefer…

About Sam Dickinson

Senior Software Developer
Having been in the industry for more years than I care to mention, I have seen various techniques come and go, and have enjoyed the ride they have taken me on and love keeping up to date with everything new and shiny.

Comments are closed.