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; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser:
Chrome 138
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
foreach
8.4M/s
some
8.4M/s
every
8.4M/s
map
7.0M/s
for
4.6M/s
for..of
992K/s
View exact numbers
Test name
Executions per second
✓
foreach
8,436,408 Ops/sec
some
8,396,743 Ops/sec
every
8,377,744 Ops/sec
map
7,015,922 Ops/sec
for
4,587,116 Ops/sec
for..of
991,812 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);