Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
find() vs for...of vs for-loop 2
(version: 0)
Testing the difference between native loops and find()
Comparing performance of:
for-loop vs for..of vs Array.find()
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id='test'></div>
Tests:
for-loop
var arr = ['hello', 'a', 'b']; let val; for(i=0; i<arr.length; i++){ if (arr[i] === 'b') { val = arr[i]; break; } }
for..of
var arr = ['hello', 'a', 'b']; let val; for (var value of arr) { if (value === 'b') { val = value; break; } }
Array.find()
var arr = ['hello', 'a', 'b']; let val = arr.find(node => node.id === 'b');
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:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
loop vs recursion
loop vs recursion
Array fill foreach, vs for i loop
foreach vs for..of
foreach vs for...of
Comments
Confirm delete:
Do you really want to delete benchmark?