Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for loop vs array.forEach - on regular looping use
(version: 0)
Comparing performance of:
for loop vs array.forEach
Created:
one year ago
by:
Guest
Go to the latest result
Tests:
for loop
for (let i = 1; i <= 1000; i++) { console.log(i); }
array.forEach
[...Array(1000)].forEach((val,i,arr) => console.log(i+1));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
for loop
array.forEach
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36 EdgA/130.0.0.0
Browser/OS:
Chrome Mobile 130 on Android
View result in a separate tab
Embed
Embed Benchmark Result
for loop
47/s
array.forEach
47/s
View exact numbers
Test name
Executions per second
✓
for loop
47 Ops/sec
array.forEach
47 Ops/sec
Related benchmarks
foreach vs for..of
for (i < n) vs forEach vs for...of
foreach vs for...of
For loop vs <Array>.forEach() vs for...of loop
forEach vs for of 7
Comments
Confirm delete:
Do you really want to delete benchmark?