For loop, basic | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
for (var i = 0; i < arr.length; i++) {
someFn(arr[i]);
}
| ready |
While loop, basic | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
var i = 0;
while (i < arr.length) {
someFn(arr[i]);
i++;
}
| ready |
For loop, cached | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
for (var i = 0, len = arr.length; i < len; i++) {
someFn(arr[i]);
}
| ready |
For loop, i-- | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
for (var i = arr.length; i > 0; i--) {
someFn(arr[i]);
}
| ready |
Do-while loop, i-- | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
var i = arr.length - 1;
do {
someFn(arr[i]);
}
while (i--);
| ready |
Do-while loop, --i | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
var i = arr.length;
if (i > 0) {
do {
someFn(arr[i]);
}
while (--i);
}
| ready |
For..in loop | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
for (var i in arr) {
someFn(arr[i]);
}
| ready |
Order | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
while (i = arr.shift()) {
someFn(i);
}
| ready |
forEach | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
arr.forEach(function(v) {
someFn(v)
})
| ready |
order validation | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
while ((i = arr.shift()) !== undefined) {
someFn(i);
}
| ready |
While ! Undefined | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
var a;
while ((a = arr[i++]) !== undefined) {
someFn(a);
}
| ready |
Pop | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
while (i = arr.pop()) {
someFn(i);
newArr.push(i);
}
| ready |
Order w/ array copy | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
var copy = arr.slice(0);
while (i = copy.shift()) {
someFn(i);
}
| ready |
Pop w/ reverse() | var arr = [],
newArr = [];
for (var i = 0; i < 1000; i++) {
arr[i] = i;
}
arr.reverse();
while (i = arr.pop()) {
someFn(i);
newArr.push(i);
}
| ready |