Empty array (v174)

Revision 174 of this benchmark created by Dallas62 on


Setup

var sourceArray = [];
  
  for (i = 0; i < 100000; i++)
    sourceArray.push({
      a: 1,
      b: "2"
    });

Test runner

Ready to run.

Testing in
TestOps/sec
length
var arr = sourceArray.slice();

arr.length = 0;
ready
splice
var arr = sourceArray.slice();

arr.splice(0, arr.length);
ready
pop
var arr = sourceArray.slice();

while (arr.length > 0) {
  arr.pop();
}
ready
pop
var arr = sourceArray.slice();

while (arr.length) {
  arr.pop();
}
ready
shift
var arr = sourceArray.slice();

while (arr.length > 0) {
  arr.shift();
}
ready
shift
var arr = sourceArray.slice();

while (arr.length) {
  arr.shift();
}
ready
empty
var arr = sourceArray.slice();

arr = [];
ready

Revisions

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