[] vs Array for object conversion

JavaScript performance comparison

Revision 9 of this test case created by ecmanaut

Preparation code

<script>
  // Initialize
  var result, array = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' '),
      Array_prototype_slice = Array.prototype.slice;
  
  // "result" is used to prevent memory leaks found on tests.
</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
[].slice()
result = array.slice();
pending…
[].slice.call
result = array.slice.call(array);
pending…
[].slice.apply
result = array.slice.apply(array);
pending…
Array.prototype.slice.call
result = Array.prototype.slice.call(array);
pending…
Array.prototype.slice.apply
result = Array.prototype.slice.apply(array);
pending…
(Saved Array.prototype.slice)()
result = Array_prototype_slice(array);
pending…
(Saved Array.prototype.slice).call
result = Array_prototype_slice.call(array);
pending…
(Saved Array.prototype.slice).apply
result = Array_prototype_slice.apply(array);
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