Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
For vs for of vs forEach
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser:
Firefox 147
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one month ago
Test name
Executions per second
for loop
4858.8 Ops/sec
forEach
7063.5 Ops/sec
for of
1557.9 Ops/sec
reduce
6489.1 Ops/sec
Script Preparation code:
var array = new Array(100000);
Tests:
for loop
let value; for (var i = 0; i < array.length; i++) { value = array[i]; }
forEach
let value; array.forEach(function(i) { value = i; });
for of
let value; for (var i of array) { value = i; }
reduce
const value = array.reduce((prev, current) => current, null)