Jquery each vs Underscore each vs For loops (v3)

Revision 3 of this benchmark created by Roberto Huertas on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js">
</script>

for (var i = 0; i < 10000; i++) {
    arr.push({ Number: i });
}

Setup

var arr = [];

Test runner

Ready to run.

Testing in
TestOps/sec
Jquery each
$.each(arr, function (i, o) { var e=o  }); 
 
ready
Underscore each
_.each(arr, function (o) { var e=o ; });
ready
For normal
for (var j = 0; j<=arr.length; j++) { var e=arr[j]; } 
 
ready
For in
for (var k in arr) { var e=arr[k]; } 
 
ready
For normal 2
for (var l = 0,len=arr.length; l<=len; l++) { var e=arr[l]; } 
ready

Revisions

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