DEV Community

Discussion on: How To For Loop Through Anything in JS

Collapse
 
jacobmparis profile image
Jacob Paris

That depends what you're measuring

Most of the time a for loop takes up is spent doing logic on each iteration. The amount of time it takes to switch from the end of one iteration to another (which is the only way these differ) is microscopic in comparison.

Unless you're doing many thousands of iterations, performance is the wrong heuristic to help you decide