DEV Community

Discussion on: What the... iterators?

Collapse
 
cmelgarejo profile image
Christian Melgarejo

What about the speed on iterables? How do they compare with the ol'mighty for(;;)?

Collapse
 
genta profile image
Fabio Russo • Edited

I think the big difference is in readability.
If we consider that many types of "loops" hide the "iterator" property as forEach, what makes a difference for us is, for example, that forEach can not be interrupted.
Most of the times “for” is faster... but that kind of difference, on speed, is really not a big deal.