Test case details

Preparation Code

<script> // Populate the base array var arr = []; for (var i = 0; i < 1000; i++) { arr[i] = i; } function someFn(ix) { return ix * 5 + 1 / 3 * 8; } </script>

Test cases

Test #1

for (var i = 0; i < arr.length; i++) { someFn(arr[i]); }

Test #2

var i = 0; while (i < arr.length) { someFn(arr[i]); i++; }

Test #3

for (var i = 0, len = arr.length; i < len; i++) { someFn(arr[i]); }

Test #4

for (var i = arr.length; i > 0; i--) { someFn(arr[i]); }

Test #5

var i = arr.length - 1; do { someFn(arr[i]); } while (i--);

Test #6

var i = arr.length; if (i > 0) { do { someFn(arr[i]); } while (--i); }

Test #7

for (var i in arr) { someFn(arr[i]); }

Test #8

while (i = arr.shift()) { someFn(i); }

Test #9

arr.forEach(function(v) { someFn(v) })

Test #10

while ((i = arr.shift()) !== undefined) { someFn(i); }

Test #11

var a; while ((a = arr[i++]) !== undefined) { someFn(a); }

Test #12

while (i = arr.pop()) { someFn(i); }

Test #13

var copy = arr.slice(0); while (i = copy.shift()) { someFn(i); }

Test #14

for (var i = 0, val; i < arr.length; i++) { someFn(val = arr.shift()); arr.push(val); }