3 ms·
for-of works with any iterable. break/return/throw work as expected. I imagine (eventually if not already) for-of will be slightly more performant, but that's
by tlrobinson 10y ago
for-of works with any iterable.
break/return/throw work as expected.
I imagine (eventually if not already) for-of will be slightly more performant, but that's just a hunch.
Personally I find the for-of syntax more readable.
- Klathmon 10y agoNot only that, but in the future when async/await lands (or right now if you are willing to compile and can put up with potential breakage), for-of becomes a godsend. The lack of inner functions means that you can await during part of a loop without a bunch of fuckery with the inner function with forEach.