Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
foreach vs for vs for in
(version: 0)
Comparing performance of:
forEach vs for vs for in
Created:
5 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var a = Array(400).fill(0) var i = 0;
Tests:
forEach
a.forEach(d=>++i);
for
for (; i < a.length;) {const d=a[i];++i}
for in
for(const key in a){++i;}
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
forEach
for
for in
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
forEach
40852.0 Ops/sec
for
76634248.0 Ops/sec
for in
33702.4 Ops/sec
Related benchmarks:
Array fill foreach, vs for i loop
foreach vs for..of
Array fill map, vs for i loop
Array fill vs for i loop
Comments
Confirm delete:
Do you really want to delete benchmark?