Array pop vs splice

Benchmark created on


Description

Removing an element from the end of an array, pop vs splice.

Setup

const arr = Array.from({length: 10_000}, (_, i) => i);

Test runner

Ready to run.

Testing in
TestOps/sec
pop()
while (arr.length > 5_000) {
	arr.pop();
}
ready
splice()
while (arr.length > 5_000) {
	arr.splice(arr.length - 1, 1);
}
ready
splice() 2
while (arr.length > 5_000) {
	arr.splice(-1, 1);
}
ready

Revisions

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