jQuery.each vs. alternatives (v134)

Revision 134 of this benchmark created on


Description

Each comparisons

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
for loop
var len = a.length;
for (var i = 0; i < len; i++) {
  e = $(a[i]);
};
ready
while loop
var i = a.length - 1;

while (e = a[i--]) {
  $(e)
};
ready
reverse for
for (var i = a.length; i--;) {
  e = $(a[i]);
}
ready
While 2
var i = a.length;
while (i--) {
  e = $(a[i]);
}
ready
reverse for 2
for (var i = a.length; i -= 1;) {
  e = $(a[i]);
}
ready

Revisions

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