Array vs Object Access (v3)

Revision 3 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

window.confirm = function(){};
    var a = [0], b = { "p":0 }, c = {"0":0}, d = {"fartmaster":0};

Test runner

Ready to run.

Testing in
TestOps/sec
Array get/set
a[0] + 1;
ready
Object get/set
b.p + 1;
ready
b['p'] + 1;
ready
c['0'] + 1;
ready
d['fartmaster'] + 1;
ready

Revisions

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