Array index vs Object property

JavaScript performance comparison

Test case created

Preparation code

Benchmark.prototype.setup = function() {
    var array = [0,1,2,3,4,5],
        object = {a:0, b:0, c:0, d:0, e:0};

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 index
var a = array[0];
var b = array[1];
var c = array[2];
var d = array[3];
var e = array[4];
Object properties
var a = object.a;
var b = object.b;
var c = object.c;
var d = object.d;
var e = object.e;

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

Compare results of other browsers


Comment form temporarily disabled.

Add a comment