Jquery each vs Underscore each vs For loops (v91)

Revision 91 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/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
While
var len = arr.length,
    var i = -1;
while(++i < len) {
  var e = arr[i];
}
ready
For, cached length
var len = arr.length;
for(var i = 0, i < len, i++) {
  var e = arr[i];
}
ready

Revisions

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