Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
foreach test3
(version: 0)
Comparing performance of:
for vs foreach
Created:
6 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = []; for (var i = 0; i < 10000; i++) { arr[i] = i; } function someFn(i) { return i * 3 * 8; }
Tests:
for
for(const item of arr) { someFn(item) }
foreach
arr.forEach(i => someFn(i))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
for
foreach
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
For x for in x for of x forEach
Array loop vs foreach
Array vs object performance by Dan 2
ForEachForMap bench
Array loop for vs foreach vs map vs for..of
Comments
Confirm delete:
Do you really want to delete benchmark?