array vs object access times

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

Benchmark.prototype.setup = function() {
    var arr = ['foo', true, 'bar', {}, 'baz'],
        obj = {0: 'foo', 1: true, 2: 'bar', 3: {}, 4:'baz'};

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
array access
arr[1] + arr[2];
object access
obj[1] + obj[2];

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Comment form temporarily disabled.

Add a comment