Jquery each vs Underscore each vs For loops

Benchmark created 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>

Setup

var arr=new Array(10000);

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 (i = 0; i<=arr.length; i++) { var e=arr[i]; } 
 
ready
For in
for (i in arr) { var e=arr[i]; } 
 
ready
For in var
for (var i in arr) { var e=arr[i]; } 
ready

Revisions

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