Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
find() vs for...of vs for-loop vs reverse-for
(version: 1)
Testing the difference between native loops and find()
Comparing performance of:
for-loop vs for..of vs Array.find() vs reverse for
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id='test'></div>
Script Preparation code:
var arr = [ {text: "foo"}, {text: "bar"}, {text: "baz"}, ];
Tests:
for-loop
let val; for(var i=0; i<arr.length; i++){ var value = arr[i]; if (value.text === 'baz') { val = value; break; } }
for..of
let val; for (var value of arr) { if (value.text === 'baz') { val = value; break; } }
Array.find()
let val = arr.find(node => node.text === 'baz');
reverse for
let val; for(var i=arr.length-1; i>-1; i--){ var value = arr[i]; if (value.text === 'b') { val = value; break; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
for-loop
for..of
Array.find()
reverse for
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0
Browser/OS:
Firefox 135 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
for-loop
94802936.0 Ops/sec
for..of
32459766.0 Ops/sec
Array.find()
183797840.0 Ops/sec
reverse for
86085656.0 Ops/sec
Related benchmarks:
find() vs for...of vs for-loop
For-loop vs For-Of vs Array.find
for loop vs for of
find() vs for...of vs for-ggggloop
find() vs for...of vs for-loop more data
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
Comments
Confirm delete:
Do you really want to delete benchmark?