Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
for vs foreach vs some vs every vs for..of vs map
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0
Browser:
Firefox 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
for
7.9M/s
every
4.6M/s
foreach
4.3M/s
some
3.6M/s
map
2.4M/s
for..of
511K/s
View exact numbers
Test name
Executions per second
✓
for
7,892,260 Ops/sec
every
4,576,731 Ops/sec
foreach
4,285,001 Ops/sec
some
3,554,845 Ops/sec
map
2,444,406 Ops/sec
for..of
511,384 Ops/sec
Script Preparation code:
var array = new Array(100);
Tests:
for
for (var i = 0; i < array.length; i++) { array[i]; }
foreach
array.forEach(function(i) { array[i]; });
some
array.some(function(i) { array[i]; });
every
array.every(function(i) { array[i]; });
for..of
for (var i of array) { array[i]; }
map
array.map(a => a);