Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
find() vs for...of vs for-loop v2
Testing the difference between native loops and find()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Browser:
Chrome 144
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
for-loop
19701248.0 Ops/sec
for..of
156358640.0 Ops/sec
Array.find()
110861784.0 Ops/sec
HTML Preparation code:
<div id='test'></div>
Tests:
for-loop
var arr = ['hello', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']; let val; for(i=0; i<arr.length; i++){ var value = arr[i]; if (value === 'b') { val = value; break; } }
for..of
var arr = ['hello', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']; let val; for (var value of arr) { if (value === 'b') { val = value; break; } }
Array.find()
var arr = ['hello', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']; let val = arr.find(node => node.id === 'b');