Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
get first element
(version: 1)
Comparing performance of:
[0] vs for...loop vs find
Created:
11 months ago
by:
Guest
Jump to the latest result
Tests:
[0]
const a = [1,2,3,4,5,6,6,7]; a[0]
for...loop
const a = [1,2,3,4,5,6,6,7]; for (let i = 0; i < a.length; i++) { const el = a[i] if (el != null) { return el } }
find
const a = [1,2,3,4,5,6,6,7] a.find(e => e!= null)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
[0]
for...loop
find
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
[0]
157031792.0 Ops/sec
for...loop
161687760.0 Ops/sec
find
97288208.0 Ops/sec
Related benchmarks:
Array initialization
For loop initialization.
testing js
i++ vs ++i vs i += 1 vs i = i + 1
loopstestjs
compare loops
compare loops 2
Includes VS new Set
array.indexof vs for
Comments
Confirm delete:
Do you really want to delete benchmark?