DEV Community

loading...

Discussion on: In JS how do you know the right condition to use inside your for loop?

Collapse
aakatev profile image
Artem

If you struggle with it, you are no alone.

That's why modern languages introduces a concept of iterator or iterator methods. In JS, you can use forEach to achieve similar purpose of a for loop. There are also for ... in and for ... of loops where you don't have to care about indexes.

Collapse
scothinks profile image
Forem Open with the Forem app