Array clear methods (v24)

Revision 24 of this benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
redefine
var b = a.concat();
a = [];
ready
length=0
var b = a.concat();
a.length = 0;
ready
a.pop();
var b = [];
while (a.length > 0) {
  b.push(a.shift());
}
ready
a.splice(0,a.length)
var b = a.splice(0, a.length);
ready

Revisions

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