Inverter Array (v2)

Revision 2 of this benchmark created on


Setup

var array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
  var length = array.length;

Test runner

Ready to run.

Testing in
TestOps/sec
Reverse
array.reverse();
ready
Ciclo for com swap
var left = null;
var right = null;
for (left = 0, right = length - 1; left < right; left += 1, right -= 1) {
  var temporary = array[left];
  array[left] = array[right];
  array[right] = temporary;
}
ready
Map
array = array.map(function (item, indice, array) {
  return array[array.length - indice - 1]
});
ready

Revisions

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