Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
while vs for vs forEach vs for of - 1000000 - calc
Compare the new ES6 spread operator with the traditional concat() method and push
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/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
while
969.7 Ops/sec
for
892.2 Ops/sec
forEach
84817.3 Ops/sec
for of
338432.1 Ops/sec
Script Preparation code:
var arr =new Array(10000);
Tests:
while
let i=0; while(i < arr.length) { const exp = arr[i] ** 2; i++; }
for
for(let i=0; i<arr.length; i++) { const exp = arr[i] ** 2; }
forEach
arr.forEach((element) => { const exp = element ** 2; });
for of
for(const element of arr) { const exp = element ** 2; }