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
Jump 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
Test name
Executions per second
for loop
47.0 Ops/sec
array.forEach
46.7 Ops/sec
Related benchmarks:
Regular for vs forEach
for vs foreach var array = new Array(100);
Loop Test (forEach vs for)
foreach vs for..of
for (i < n) vs forEach vs for...of
foreach vs for...of
for of vs forEach with console log
For loop vs <Array>.forEach() vs for...of loop
for vs foreach123
forEach vs for of 7
Comments
Confirm delete:
Do you really want to delete benchmark?