jQuery.each vs. for loop (v211)

Revision 211 of this benchmark created by pavelrevers on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var a = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a".split(","), //100 items,
      e;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.each
$.each(a, function(index, obj) { e = index; })
ready
for loop
for (var i = 0, len = a.length; i < len; i++) { e = i; }
ready
for without caching
for (var i = 0; i < a.length; i++) { e = i; }
ready
alternative for loop
for (var i in a) { e = i; }
ready
reverse for
for (var i = a.length; i--;) { e = i; }
ready
while reverse
var i = a.length;
while(i){ e = --i }
ready
for loop (i += 1)
for (var i = 0, len = a.length; i < len; i += 1) { e = i; }
ready

Revisions

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