DEV Community

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

_prosen profile image
Prosen Ghosh Author • Edited on

yes, that is the point of my post how we can write good quality code, where can we do the mitake? if we do mistake in our code it can be affect the performance and create unnecessary bug.

Thread Thread
jasoncubic profile image

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.