DEV Community

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

Collapse
 
_prosen profile image
Prosen Ghosh • Edited

You are right Adam,

const array = new Array(10); // JUST FOR EXAMPLE, WE DON'T DO IT IN REAL LIFE
Enter fullscreen mode Exit fullscreen mode

no one going to create an empty slot for an array, it can happen accidentally/unintentionally and it can be bad for our application performance that is the whole point of this post.

i have updated my post using a relevant code example. Please take a look.

Thanks for your feedback.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Graciously I admit I did learn more foibles about the forEach method in this post, not iterating over empties is not what I expected at all, thanks for bringing it up!