for++ or while-- (v8)

Revision 8 of this benchmark created by Anton on


Test runner

Ready to run.

Testing in
TestOps/sec
for++
function name(arr) {
  var i = 0,
    max = arr.length,
    res = [];
  for (i = 0; i < max; i++) {
    res.push(arr[i]);
  }
  return res;
}
console.log(name([1, 2, 3]));
ready
while--
function name(arr) {
  var i = arr.length,
    res = [];
  while (i--) {
    res.push(arr[i]);
  }
  return res;
}
console.log(name([1, 2, 3]));
ready

Revisions

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