Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
iterating through arrays (for .. of vs forEach) [noop in for of]
(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) { noop() }
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:
10 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0
Browser/OS:
Firefox 139 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
for .. of
359933.9 Ops/sec
forEach
1870478.9 Ops/sec
Related benchmarks:
for vs foreach vs for..of (aprudnikov)
for vs foreach vs some vs for..of test 2
for vs foreach vs for..of vs for..of over entries (const)
for vs for..of vs for..in vs foreach
for vs array.foreach vs for..in vs for..of
for vs foreach vs for..in vs for..of v2
for vs foreach vs for..of vs for..of over entries with big number of elements
access arr element and multiply it in loops: for vs forEach vs for..in
iterating through arrays (for .. of vs forEach
Comments
Confirm delete:
Do you really want to delete benchmark?