January 6, 2026
For-of and Furious
JavaScript's For-Of Loops Are Fast
Fast-ish: devs split between “wow” and “show me proof”
TLDR: A new test says JavaScript’s for-of loop can run nearly as fast as the classic for loop on Chrome after warmup, while forEach trails. Commenters are split: skeptics question the benchmark’s design and engine bias, others share alternative tests, and many say the real verdict depends on the browser engine.
JavaScript’s latest drama: a fresh benchmark says the friendlier for-of loop can run nearly neck-and-neck with the old-school for loop—at least on Google’s Chrome engine after warming up. The tester ran six loop styles across different array sizes and types, finding for-of close to the classic “cached length” loop, forEach lagging, reverse loops weirdly hurting, and for-in bringing up the rear. At huge sizes, for-of dipped—until they repeated it 200 times, letting the engine “warm up,” after which it nearly caught up again.
Cue the comment section turning into the Loop Olympics. One camp is not impressed: “But still just 85%…” snaps user phillipseamore, number-crunching like it’s tax season. Skeptics go harder: panstromek warns there are “so many ways this benchmark can go wrong,” side-eyeing the mysterious dummy function meant to keep the engine honest—“what is ‘too much’?” Meanwhile, pjmlp fires a meta-hot take: don’t say “JavaScript is fast,” say “V8 (Chrome’s engine) made this fast,” pointing to the many engines in the JS zoo. Others throw in receipts with throwback tools like jsperf.
The vibe? Equal parts celebration and side-eye. Jokes land about JavaScript having “too many ways to loop” while the functional-programming crowd flexes, “Racket goes further.” The takeaway: for-of might be faster than you think, but the community wants broader tests, more engines, and fewer vibes—until the next benchmark drops, of course.
Key Points
- •Benchmarks compared six JavaScript loop types across five data shapes and three array sizes (5,000, 50,000, 500,000).
- •Tests were run sequentially on Chrome 143, Windows 11, with an AMD Ryzen 5000U using jsbenchmark.com.
- •For 5,000 and 50,000 elements, for-of performed close to classic for with cached length; for-in was slowest.
- •At 500,000 elements, for-of and forEach became less optimal, especially with floats, likely due to limited optimization.
- •A 200-iteration warmup brought for-of closer to cached-length classic for; forEach showed little improvement.