JQuery.grep vs Javascript Filter

Benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var array = []
    for(var i = 0; i < 100000; i++){
      array.push(i);
    }
    
    var filter = function(item){
      return item %3;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Jquery Grep
result = $.grep(array,filter)
ready
Filter
result = array.filter(filter)
ready
Push
result = []
for(var i = 0; i < array.length; i++){
   if(filter(array[i]))
       result.push(array[i]);
}
ready

Revisions

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