loading...

re: Don’t use for loop for JavaScript Arrays VIEW POST

FULL DISCUSSION
 

There are still perfectly valid use cases for the for loop. For example, if you want to break out of the loop early there’s the break keyword.

Or if you want to not iterate over the items of an array, but rather just repeat something a certain number of times, a for loop is useful there too.

A for loop also lets you have more complex logic for when you should continue looping. Remember that for loops are not only used for iterating over an array.

 

Some comments have been hidden by the post's author - find out more

code of conduct - report abuse