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 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
for
27.3M/s
every
13.9M/s
foreach
13.9M/s
some
13.8M/s
map
9.0M/s
for..of
2.2M/s
View exact numbers
Test name
Executions per second
✓
for
27,288,732 Ops/sec
every
13,892,648 Ops/sec
foreach
13,861,098 Ops/sec
some
13,780,809 Ops/sec
map
8,990,175 Ops/sec
for..of
2,219,821 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);