pop vs slice

Benchmark created by Andrew Hare on


Description

What is the fastest way to remove the last element of an array and return what remains.

Test runner

Ready to run.

Testing in
TestOps/sec
pop
var l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
l.pop();
ready
slice
var l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
l.slice(0, (l.length - 1));
ready

Revisions

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