Yes, here are some benchmarks run by Mehdi Khadir 2016 that tests (for…of loop, for loop, loadash’s foreach loop and reversed loop).

In short, the conventional for loop is faster than for…of, but the fastest one is Reversed loop (I just discovered this).

“ The reversed loop is an improved variation of the for-loop, as the length of the array is calculated only one time.”

In general, milliseconds is extremely fast, and if you just need to loop through a list of 100 or 500 items, then you won’t notice any performance delay. But if that list is more than thousands of items then maybe you should consider types of loops.

Software Engineer sharing interesting tech topics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store