DEV Community

Discussion on: Why is using javascript “for loop” for array iteration a bad idea?

 
jasoncubic profile image
JasonCubic

It's still a micro optimization. The for loop can loop through 400 empty places in an array in what, 5ms? It's extremely fast.

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️

Precisely - and by addressing the symptom rather than the cause i.e. by switching from a 'for loop' to forEach - you would actually be making the performance of the optimal (bug fixed) system worse than before.