for and each

Benchmark created on


Preparation HTML

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

  };
</script>

Setup

Benchmark.prototype.setup = function() {
    <script>
    var arr = [];
    for(var i = 0; i<100000; i++)
    {
      arr[i] = i;
    }
    var len = arr.length;

Test runner

Ready to run.

Testing in
TestOps/sec
forloop
for(var i = 0; i < arr.length; i++)
{
        if(i%100 == 0){console.log(1)}
}
ready
jquery each
$.each(arr,function(i,obj){
        if(i%100 == 0){console.log(1)}
});
ready

Revisions

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