Script Preparation code:
x
 
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>

Previous results

Experimental features:

  • Test case name Result
    Find1
    Find2
    Some1
    Some2

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36
Chrome 95 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Find1 3545240.2 Ops/sec
Find2 3544823.2 Ops/sec
Some1 3106454.2 Ops/sec
Some2 3068843.8 Ops/sec