Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Several Some vs One Find
(version: 4)
Comparing performance of:
Find1 vs Find2 vs Some1 vs Some2
Created:
4 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var arr = [{ type: 'This Thing' }, { type: 'Something Else' }]; var arr2 = [{ type: 'SomethingElse' }, { type: 'Something Else' }] function _find(items) { let hasThisThing = false; let hasSomethingElse = false; return arr.find(item => { const isThisThing = item.type === 'This Thing'; hasThisThing = hasThisThing || isThisThing; hasSomethingElse = hasSomethingElse || !isThisThing; return hasThisThing && hasSomethingElse; }); } function _some(items) { let hasThisThing = arr.some(item => item.type === 'This Thing'); let hasSomethingElse; if (hasThisThing) { hasSomethingElse = arr.some(item => item.type !== 'This Thing'); } return hasThisThing && hasSomethingElse; }
Tests:
Find1
_find(arr)
Find2
_find(arr2)
Some1
_some(arr)
Some2
_some(arr2)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Find1
Find2
Some1
Some2
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:
Testing for false vs === undefined vs hasOwnProperty for undefined member
undefined vs. typeof vs. in vs. hasOwnProperty vs exists vs double bang
undefined vs. typeof vs. in vs. hasOwnProperty 25
undefined vs. typeof vs. in vs. hasOwnProperty 1000 items
?. operator vs. getProperty
Comments
Confirm delete:
Do you really want to delete benchmark?