Jquery each vs Underscore each vs For loops (v54)

Revision 54 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.1/underscore-min.js"></script>

Setup

var arr = new Array(10000);
    function arrayfunc(el, key)
    {
         var e = el;
    }

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
For in var with function
for (var i in arr) {
  arrayfunc(arr[i], i);
}
ready

Revisions

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