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 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser:
Firefox 146
Operating system:
Windows
Device Platform:
Desktop
Date tested:
6 months ago
for loop
5K/s
forEach
4K/s
reduce
4K/s
for of
828/s
View exact numbers
Test name
Executions per second
✓
for loop
5,367 Ops/sec
forEach
4,087 Ops/sec
reduce
3,971 Ops/sec
for of
828 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)