Array.prototype.slice.call() vs [].slice.call() nested (v7)

Revision 7 of this benchmark created on


Description

caching the prototype lookup should be fastest...

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var items = [1, 2, 3, 4, 5],
      slice = Array.prototype.slice,
      _slice = [].slice;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Array.prototype.slice
(function() {
var x;
(function() {
var y = 9;
(function() {
var z = 3;
Array.prototype.slice.call(items);
})()
})()
})()
ready
[].slice
(function() {
var x;
(function() {
var y = 9;
(function() {
var z = 3;
[].slice.call(items);
})()
})()
})()
ready
cached prototype
(function() {
var x;
(function() {
var y = 9;
(function() {
var z = 3;
slice.call(items);
})()
})()
})()
ready
cached [].slice
(function() {
var x;
(function() {
var y = 9;
(function() {
var z = 3;
_slice.call(items);
})()
})()
})()
ready
Array().slice
(function() {
var x;
(function() {
var y = 9;
(function() {
var z = 3;
Array().slice.call(items);
})()
})()
})()
ready

Revisions

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