Array vs Object Access (v7)

Revision 7 of this benchmark created 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= {"a":1, "b":2, "c":3, "d":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.a;
o.b;
o.c;
o.d;
ready
Object access 2
o["a"];
o["b"];
o["c"];
o["d"];
ready
Object access Numbers
o["5"];
o["6"];
o["7"];
o["8"];
ready

Revisions

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