Array Assignment vs Array Push

Benchmark created by Rick Waldron on


Description

You've heard the rumors - now here's the proof.

Test runner

Ready to run.

Testing in
TestOps/sec
arrayA[arrayA.length] = 'foo';
var arrayA = [];
for (var i = 0; i < 2000; i++) {
  arrayA[arrayA.length] = 'foo';
}
ready
arrayB.push('foo');
var arrayB = [];
for (var i = 0; i < 2000; i++) {
  arrayB.push('foo');
}
ready

Revisions

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