Lodash find vs native find 2017

Benchmark created by Kitus on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script>

Setup

list = [];
  
  for (var i = 0; i < 10000; i++) {
    list.push({
      name: "random" + Math.random(),
      age: "random" + Math.random(),
      id: i,
      title: "random" + Math.random(),
    });
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Native
var element;
element = list.find(function(item) { return item.id === 1 });
element = list.find(function(item) { return item.id === 5000 });
element = list.find(function(item) { return item.id === 9999 });
ready
lodash callback
var element;
element  = _.find(list, function(item) { return item.id === 1 });
element  = _.find(list, function(item) { return item.id === 5000 });
element  = _.find(list, function(item) { return item.id === 9999 });
ready
lodash object
var element;
element = _.find(list, { id: 1 });
element = _.find(list, { id: 5000 });
element = _.find(list, { id: 9999 });
ready
lodash key value
var element;
element = _.find(list, "id", 1);
element = _.find(list, "id", 5000);
element = _.find(list, "id", 9999);
ready

Revisions

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