Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for vs foreach vs for..of (1)
(version: 1)
Compare loop performance
Comparing performance of:
for vs foreach vs for..of
Created:
one year ago
by:
Guest
Go to the latest result
Script Preparation code:
var array = new Array(100_000_000);
Tests:
for
for (var i = 0; i < array.length; i++) { array[i]; }
foreach
array.forEach(function(i) { array[i]; });
for..of
for (var i of array) { array[i]; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
for
foreach
for..of
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
for
2/s
foreach
1/s
for..of
1/s
View exact numbers
Test name
Executions per second
✓
for
2 Ops/sec
foreach
1 Ops/sec
for..of
1 Ops/sec
Related benchmarks
for vs foreach vs for..in vs for..of
for vs foreach vs for..in vs for..of 2
for vs foreach vs for...in vs for...of
for vs foreach vs for..in vs for..of skidson
Comments
Confirm delete:
Do you really want to delete benchmark?