Array.filter vs lodash filter

JavaScript performance comparison

Test case created by steve and last updated

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var values = [];
   
    for (var i = 0; i < 100; i++) {
      values.push(i);
    }
   
    function isEven(value) {
      return (value % 2 === 0);
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
lodash
_.filter(values, isEven);
pending…
Array.filter
values.filter(isEven);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment