HTML Preparation code:
x
 
1
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.js"></script>
2
Script Preparation code:
 
var strings = [
    'one', 'two', 'three'
]
var regex = /^(one|two|three)$/;
var input = 'three'
Tests:
  • array find

     
    // Native
    !!strings.find(function (o) { return o == input; })
  • _.find

     
    !!_.find(strings, function (o) { return o==input; })
  • regex

     
    regex.test(input)
  • regex (i)

     
    regex.test(input)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    array find
    _.find
    regex
    regex (i)

    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/91.0.4472.106 Safari/537.36
Chrome 91 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
array find 2878186.5 Ops/sec
_.find 1553211.2 Ops/sec
regex 3349807.2 Ops/sec
regex (i) 3453665.8 Ops/sec