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.
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.
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.
If you're accidentally setting
array[400]
then that is your problem, and it needs fixing. The heavy calculation is merely a side effect of your bugyes, 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.
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.
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.