jQuery.each vs. for loop (v238)

Revision 238 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/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
while loop
var i = a.length - 1;

while (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
lowdash each
_.each(a, function(i) {
  e = i;
});
ready

Revisions

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