Get last item from array (v14)

Revision 14 of this benchmark created by Joshua on


Preparation HTML

<script>
Array.prototype.last = function() {
  return this[this.length-1];
};
var array = [1,2,3,5,4,6,85,2,5,7,4,4,4,234,23];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
array[array.length - 1]
array[array.length - 1];
ready
array.slice(-1)[0];
array.slice(-1)[0];
ready
array.slice().pop();
array.slice().pop();
ready
[].concat(array).pop();
[].concat(array).pop();
ready
array.last();
array.last();
ready

Revisions

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