lodash contains vs native indexof (v6)

Revision 6 of this benchmark created by Guy on


Description

create lodash object

Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.2.1/lodash.min.js"></script>

Setup

var arr = [];
        for (var i = 0; i < 10000; i++) {
          arr.push('abc' + i);
        }

Test runner

Ready to run.

Testing in
TestOps/sec
_.contains
var number = Math.floor(Math.random() * 10000);
var result = _.contains(arr, 'abc' + number);
ready
lodash indexof
var number = Math.floor(Math.random() * 10000);
var result = _.indexOf(arr, 'abc' + number) > -1;
ready
Native indexOf
var number = Math.floor(Math.random() * 10000);
var result = arr.indexOf('abc' + number) > -1;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.