Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
access arr element and multiply it in loops: for vs forEach vs for..in
Compare loop performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0
Browser:
Firefox 117
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
for
1045574.8 Ops/sec
foreach
113247.8 Ops/sec
for..in
16197.4 Ops/sec
Script Preparation code:
var array = [...new Array(1000)].map((e, i) => i + 1);
Tests:
for
for (var i = 0; i < array.length; i++) { array[i] = array[i] * 1000; }
foreach
array.forEach((e, i) => { array[i] = e * 1000; });
for..in
for (var i in array) { array[i] = array[i] * 1000; }