Browser Diet - jQuery.each vs. for loop (v13)

Revision 13 of this benchmark created on


Description

Added lodash's each.

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.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
for (var i = 0, len = a.length; i < len; i++) { e = a[i]; }
ready
for without caching
for (var i = 0; i < a.length; i++) { e = a[i]; }
ready
alternative for loop
for (var i in a) { e = a[i]; }
ready
reverse for
for (var i = a.length; i--;) { e = a[i]; }
ready
while reverse
var i = a.length;
while(i){ e = a[--i] }
ready
while
var i = a.length;
while(!i){ e = a[++i] }
ready
lodash.each
_.each(a, function(item) { e = item; })
ready

Revisions

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