Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array for vs Array for of vs Set for of vs Set forEach * 1000
(version: 0)
Testing the difference between native loops and find()
Comparing performance of:
Array for-loop vs Array for..of vs Set for of vs Set forEach vs Array for i
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id='test'></div>
Script Preparation code:
window.fn = function fn() {} window.arr = new Array(1000).fill(0).map((x, i) => i.toString()); window.set = new Set(arr);
Tests:
Array for-loop
for(i=0, l = arr.length; i<l; i++){ fn(arr[i]); }
Array for..of
for (let value of arr) { fn(value); }
Set for of
for (let value of set) { fn(value); }
Set forEach
set.forEach(value => fn(value));
Array for i
for (let i = 0; i < arr.length; i++) { val = myArray[i] fn(val); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Array for-loop
Array for..of
Set for of
Set forEach
Array for i
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?