jQuery.each vs. for loop (v175)

Revision 175 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="//underscorejs.org/underscore-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
var len = a.length,
    i = -1;
for (;++i < len;) {
  e = a[i]
}
ready
prepare vars
var len = a.length,
    i;
for (i = 0; i < len; i++) {
  e = a[i]
}
ready
while -- prepared
var i = a.length;

while (i--) {
  e = a[i]
}
ready

Revisions

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