Zero filled array creation (v37)

Revision 37 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Array push
for (var i = 0, a = []; i < 100; i++) a.push(0);
ready
Array assign
var i = 0;
var a = new Array(100)
for (i = 0; i < 100; i += 1) {
  a[i] = 0;
}
ready
Typed array conversion
[].slice.call(new Uint8Array(100));
ready
Binary concatenation
for (var i = 100, a = [], add = [0]; i; i >>= 1) {
  if (i & 1) a.push.apply(a, add);
  add.push.apply(add, add);
}
ready
Array Apply
Array.apply(null, new Array(100)).map(Number.prototype.valueOf, 0);
ready
Anonymous function while()
(function(n) {
  while (n-- && this.push(n));
  return this;
}).call([], 100);
ready
Anonymous function for()
(function(n) {
  for (; n--; this.push(0));
  return this;
}).call([], 100);
ready
plusplus
var i = 0;
var a = new Array(100)
for (i = 0; i < 100; i++) {
  a[i] = 0;
}
ready
Array.fill
var a = new Array(100);
a.fill(0);
ready

Revisions

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