Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
iterating through arrays (for .. of vs forEach
(version: 1)
compare for ..of iteration speed with forEach method
Comparing performance of:
for .. of vs forEach
Created:
10 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
globalThis.testArray = Array(1000).fill(0).map((_, i) => i); globalThis.noop = () => {};
Tests:
for .. of
for (const v of testArray) {}
forEach
testArray.forEach(noop);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
for .. of
forEach
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 Edg/143.0.0.0
Browser/OS:
Chrome 143 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
for .. of
3675987.5 Ops/sec
forEach
3656321.5 Ops/sec
Related benchmarks:
for vs foreach vs for..of (aprudnikov)
for vs foreach vs some vs for..of - henrique
for vs foreach vs for..of vs for..of over entries
for vs foreach vs for..of vs for..of over entries (const)
for-in vs foreach vs for-of
for vs foreach vs for..in vs for..of test
for vs foreach vs for..of vs for..of over entries vs for in
for vs foreach vs for..of vs for..of over entries (const) etc
for vs foreach vs for..of vs for..of over large entries
Comments
Confirm delete:
Do you really want to delete benchmark?