Array vs Object Access

Benchmark created by Matt Marston on


Description

JavaScript arrays are basically just objects with integer property names. Is there any performance difference when accessing an array vs an object?

Setup

var a = [0], b = { "0":0 };

Test runner

Ready to run.

Testing in
TestOps/sec
Array get/set
a[0] = a[0] + 1;
ready
Object get/set
a["0"] = a["0"] + 1;
ready

Revisions

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