Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
For loop vs <Array>.forEach()
(version: 0)
Comparing performance of:
<Array>.forEach() vs For loop
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = Array(50000, (_, i) => i + 1);
Tests:
<Array>.forEach()
array.forEach((v, i) => `Item n°${i} : ${v}`);
For loop
for (let i = 0; i < array.length; i++) `Item n°${i} : ${array[i]}`;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
<Array>.forEach()
For loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Array fill foreach, vs for i loop
foreach vs for..of
foreach vs for...of
For loop vs <Array>.forEach() vs for...of loop
For vs Foreach vs While
Comments
Confirm delete:
Do you really want to delete benchmark?