Array.prototype.filter vs. _.find (v7)

Revision 7 of this benchmark created on


Description

Comparing Lodash's find method vs the native array filter method for finding a single item in a list

Preparation HTML

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

Setup

var array = _.shuffle(_.range(10));

Test runner

Ready to run.

Testing in
TestOps/sec
filter
var r = array.filter(function (val) {
  return val == 5;
})[0];
ready
_.find
var r = _.find(array, function (val) {
  return val == 5;
});
ready

Revisions

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