Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
find vs fors
(version: 1)
Testing the difference between native loops and find()
Comparing performance of:
for-loop vs for..of vs Array.find()
Created:
9 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id='test'></div>
Tests:
for-loop
var arr = ['a', 'b', 'test']; let val; for(i=0; i<arr.length; i++){ var value = arr[i]; if (value === 'test') { val = value; break; } }
for..of
var arr = ['a', 'b', 'test']; let val; for (var value of arr) { if (value === 'test') { val = value; break; } }
Array.find()
var arr = ['a', 'b', 'test']; let val = arr.find(node => node.id === 'test');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
for-loop
for..of
Array.find()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
for-loop
75654664.0 Ops/sec
for..of
68832424.0 Ops/sec
Array.find()
74189480.0 Ops/sec
Related benchmarks:
find() vs for...of vs for-loop
For-loop vs For-Of vs Array.find
find() vs for...of vs for-ggggloop
find() vs for...of vs for-loop 2
for...in vs for...of vs for-loop
find() vs for...of vs for-loop v2
find() vs for...of vs for-loop 2222
find() vs for...of vs for-loop vs reverse-for
for...of vs for-loop vs find()
Comments
Confirm delete:
Do you really want to delete benchmark?