Array direct assignment vs push (v101)

Revision 101 of this benchmark created by Josh Plumbly on


Setup

var array = [],
    i=0;

Test runner

Ready to run.

Testing in
TestOps/sec
Direct assignment
array[i] = "test";
i++;
 
ready
Push
array.push("test");
ready
Direct assignment (calculated)
array[array.length - 1] = "test";
ready
Direct assignment (length)
array[array.length] = "test";
ready
Increase Length & Direct Assignment
array.length += 1
array[array.length-1] = "test";
ready

Revisions

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