[] vs Array for object conversion (v9)

Revision 9 of this benchmark created by ecmanaut on


Description

In this test we look at some techniques for using Array.

Preparation HTML

<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

Ready to run.

Testing in
TestOps/sec
[].slice()
result = array.slice();
ready
[].slice.call
result = array.slice.call(array);
ready
[].slice.apply
result = array.slice.apply(array);
ready
Array.prototype.slice.call
result = Array.prototype.slice.call(array);
ready
Array.prototype.slice.apply
result = Array.prototype.slice.apply(array);
ready
(Saved Array.prototype.slice)()
result = Array_prototype_slice(array);
ready
(Saved Array.prototype.slice).call
result = Array_prototype_slice.call(array);
ready
(Saved Array.prototype.slice).apply
result = Array_prototype_slice.apply(array);
ready

Revisions

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

  • Revision 1: published by FGRibreau on
  • Revision 2: published by Robert K on
  • Revision 7: published by Leonardo Dutra on
  • Revision 9: published by ecmanaut on