Last Element Of Array

JavaScript performance comparison

Test case created by Osama

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var arrs = [], count = 6;
  
  var i, j, arr;
  
  for (i=0; i < count; i++) {
    arr = []
    for (j=0; j < Math.pow(10, i); j++) {
      arr.push(j);
    }
    arrs.push(arr);
  }

};
</script>

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
Direct access.
var arr = arrs[5];

var x = arr[arr.length - 1];
pending…
Slice(-1)
var arr = arrs[5];

var x = arr.slice(-1)[0];
pending…

Compare results of other browsers

Revisions

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

0 Comments