FOR LOOPS test (v23)

Revision 23 of this benchmark created on


Description

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

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
do ... while (i--)
var i = myArray.length - 1
var x
do { x = myArray[i] } while (i--)
ready
for loop (no caching)
var x
for (var i = 0; i < myArray.length; i++) { x = myArray[i] }
ready
for loop (with caching)
var x
for (var i = 0, l = myArray.length; i < l; i++) { x = myArray[i] }
ready
do ... while (--i)
var i = myArray.length - 1
var x
do { x = myArray[i] } while (--i >= 0)
 
ready
while (--i)
var i = myArray.length
var x
while (--i >= 0) { x = myArray[i] }
ready
while (i--)
var i = myArray.length
var x
while (i--) { x = myArray[i] }
ready
for loop (no caching, ++i)
var x
for (var i = 0; i < myArray.length; ++i) { x = myArray[i] }
ready

Revisions

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