Array.push vs Array index vs Object index

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Array.push
for(var t = [], i = 0; i < 10000; i++)
  t.push(i)
ready
Array index
for(var t = [], i = 0; i < 10000; i++)
  t[i] = i
ready
Object index
for(var t = {length:0}, i = 0; i < 10000; i++) {
  t[i] = i
  t.length++
}
ready

Revisions

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