Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for vs foreach vs some vs every vs for..of vs map / 2
(version: 0)
Compare loop performance
Comparing performance of:
for vs foreach vs some vs every vs for..of vs map
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = Array.from(Array(1000).keys());
Tests:
for
for (var i = 0; i < array.length; i++) { console.log(array[i]); }
foreach
array.forEach(function(i) { console.log(array[i]); });
some
array.some(function(i) { console.log(array[i]); });
every
array.every(function(i) { console.log(array[i]); });
for..of
for (var i of array) { console.log(array[i]); }
map
array.map(a => console.log(a));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (6)
Previous results
Fork
Test case name
Result
for
foreach
some
every
for..of
map
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:
map vs forEach Chris
map vs forEach Chris v2
map vs forEach Chris v2b
Array.forEach vs Object.keys().forEach
Array fill map, vs for i loop
Comments
Confirm delete:
Do you really want to delete benchmark?