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
Go 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:
5 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
for
76.6M/s
forEach
41K/s
for in
34K/s
View exact numbers
Test name
Executions per second
✓
for
76,634,248 Ops/sec
forEach
40,852 Ops/sec
for in
33,702 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?