Reversetest

JavaScript performance comparison

Test case created by Jake Boyles

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
One
function reverse(array) {
  var newArray = [];
  for(var x=(array.length-1);x<0;x--) {
    newArray.push(array[x]);
  }
  return newArray;
}

reverse([1,2,3,4])
pending…
Two
function reverse(array){
 const len = array.length;
 return array.map((item,idx) => array[len-1-idx])
}

reverse([1,2,3,4]);
pending…
Three
const array = [1,2,3,4];
const newArray = [...array].reverse();
pending…
Four
const array = [1,2,3,4];
const newArray = array.reverse();
pending…

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

0 Comments