Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
find() vs for...of vs for-loop large array fixed
Testing the difference between native loops and find()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Browser:
Firefox 123
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
for-loop
60038.1 Ops/sec
for..of
175157.3 Ops/sec
Array.find()
374247.3 Ops/sec
HTML Preparation code:
<div id='test'></div>
Script Preparation code:
window.arr = Array.from({ length: 1000 }, (_, i) => i)
Tests:
for-loop
let val; for(i=0; i<arr.length; i++){ var value = arr[i]; if (value === 900) { val = value; break; } }
for..of
let val; for (var value of arr) { if (value === 900) { val = value; break; } }
Array.find()
let val = arr.find(node => node === 900);