Pop vs Splice (v4)

Revision 4 of this benchmark created on


Setup

var x = [];
    for (var i = 0; i < 100; ++i) {
      x.push(i);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Pop
x[x.indexOf(5)] = x[x.length-1];
x.pop();
ready
Splice
x.splice(x.indexOf(5), 1);
ready
fish
var len = x.length-1;
x[x.indexOf(5)] = x[len];
if (len >= 0) x.length = len;
ready

Revisions

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