DEV Community

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

 
_prosen profile image
Prosen Ghosh • Edited

No one says that forEach() is faster than for...loop. For the same piece of code for..loop will be always faster then forEach() method unless we make any mistake in our code.

The above example code snippets for for..loop are written in such a way that, we can understand what can happen if we make this kind of mistake in our code.

Thread Thread
 
hasnaindev profile image
Muhammad Hasnain

Hmm. Thanks for writing the post.

Thread Thread
 
_prosen profile image
Prosen Ghosh

Thanks for giving me the feedback.