I'm Drew Town a web developer and systems engineer in Colorado. Always learning, traveling and exploring. Sharing updates, trials and tribulations in tech and life.
I realize this is not a post about whether you should use for loops or not...
I use the AirBNB linting config and they actually error when using either for...in or for...of. I think it is an interesting choice but, it can help avoid the confusion with the various for methods and the subtle changes in functionality.
It is something I have struggled with in some of my code but it seems they prefer you to use Array methods such as ForEach, map, filter. I think the biggest advantage of avoid the for loops is that it helps you reduce side-effect producing code.
The other disadvantage of for..of if you are transpiling is that it requires regenerator-runtime polyfill.
I can't say I've really missed using them in the end even if it was a bit of an adjustment.
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
All nice points. I don't know that I'm in favor of them or not. I was using them in the example in my tweet because I wanted to really break down what was happening with Object.entries. In production code I don't recall the last time I used them. But either way it was a fun deep dive into the decisions the language makes!
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.
I realize this is not a post about whether you should use
for loops
or not...I use the AirBNB linting config and they actually error when using either
for...in
orfor...of
. I think it is an interesting choice but, it can help avoid the confusion with the variousfor
methods and the subtle changes in functionality.It is something I have struggled with in some of my code but it seems they prefer you to use Array methods such as
ForEach
,map
,filter
. I think the biggest advantage of avoid the for loops is that it helps you reduce side-effect producing code.The other disadvantage of
for..of
if you are transpiling is that it requiresregenerator-runtime
polyfill.I can't say I've really missed using them in the end even if it was a bit of an adjustment.
All nice points. I don't know that I'm in favor of them or not. I was using them in the example in my tweet because I wanted to really break down what was happening with Object.entries. In production code I don't recall the last time I used them. But either way it was a fun deep dive into the decisions the language makes!