FOR LOOPS test (v16)

Revision 16 of this benchmark created on


Description

Difference between for/in, classical for loop and classical loop with caching.

Preparation HTML

<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>

Setup

var myArray = ['a', 'b', 'c', 'd'];

Test runner

Ready to run.

Testing in
TestOps/sec
for/in loop
for (var i in myArray) {}
ready
for loop (no caching)
for (var i = 0; i < myArray.length; i++) {}
ready
for loop (with caching)
for (var i = 0, l = myArray.length; i < l; i++) {}
ready
jQuery.each (for comparison)
jQuery.each(myArray, function(index, elem) {});
ready
No counter
for (var i = myArray.length; i--;){}
ready
declaration before loop
var i = 0, l = myArray.length;
for (; i < l; i++) {}
ready

Revisions

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