jQuery each vs for loop using eq

Benchmark created by Damon on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var $elements = $('<div/>').append(Array(100).join('<a></a>')).find('a');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.each
$elements.each(function() {
  $(this);
});
ready
without
for (var i=0, j=$elements.length; i < j; ++i) {
  $elements.eq(i);
}
ready

Revisions

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