Array vs Object Access (v6)

Revision 6 of this benchmark created by David 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

a= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    o= {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:10};

Test runner

Ready to run.

Testing in
TestOps/sec
Array access
a[3];
a[4];
a[6];
a[9];
ready
Object access
o[3];
o[4];
o[6];
o[9];
ready

Revisions

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