DEV Community

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

Collapse
 
jayjeckel profile image
Jay Jeckel

In the above snippet index 4 of the array is an empty slot, but the console.log will execute 5 times.

This seems to be a typo. In the example code, you initialize indexes 0, 1, and 2, then you explicitly set index 4 equal to 10, so it is index 3 that would be empty.

Collapse
 
_prosen profile image
Prosen Ghosh

Thanks Jay, fixed the typo.