For loops can be clean. In ES6 we got for..of loops, they are declarative and work with more data types than just arrays.
for(letvariableofiterable){// statement}
My only problem with for loops is that it takes discipline to extend their behavior in a "clean way." It is just so easy to go and add little if statement here and there (specially if you are under pressure) and before you know it you have block of code that is dificult to deal with.
I love for..of loops, they are the only kind of for loop I really write these days. Especially being able to do something like for (const value of object.entries()) which makes working with different types of data (not just arrays) so much nicer.
There are definitely some traps you can fall into (side effects from modifying the reference if you forget to create a new array/collection) but if you're aware of them, it's not much of a problem.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For loops can be clean. In ES6 we got for..of loops, they are declarative and work with more data types than just arrays.
My only problem with for loops is that it takes discipline to extend their behavior in a "clean way." It is just so easy to go and add little
if
statement here and there (specially if you are under pressure) and before you know it you have block of code that is dificult to deal with.I love
for..of
loops, they are the only kind of for loop I really write these days. Especially being able to do something likefor (const value of object.entries())
which makes working with different types of data (not just arrays) so much nicer.There are definitely some traps you can fall into (side effects from modifying the reference if you forget to create a new array/collection) but if you're aware of them, it's not much of a problem.