jQuery.each vs. for loop (v230)

Revision 230 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var a = $('*').get(),
      e;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.each
$.each(a, function() {
  e = this;
});
ready
for loop with closures
(function() {
    for(var i=0; i<a.length; ++i) {
        (function(index, value) {
            e = value;
        })(i, a[i]);
    }
})();
ready
basic loop
for (var i = 0; i < a.length; i++) {
  e = a[i];
};
ready

Revisions

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