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 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0
Browser:
Firefox 122
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
for
23.7M/s
foreach
17.4M/s
some
17.1M/s
every
17.1M/s
map
10.1M/s
for..of
2.1M/s
View exact numbers
Test name
Executions per second
✓
for
23,680,534 Ops/sec
foreach
17,352,824 Ops/sec
some
17,125,574 Ops/sec
every
17,061,616 Ops/sec
map
10,066,599 Ops/sec
for..of
2,061,463 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);