obj vs array

JavaScript performance comparison

Test case created

Preparation code

var ar = [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, "a"] ;
ar.indexOf("a");

var obj = {
        "b" : true ,
        "c" : true ,
        "d" : true ,
        "e" : true ,
        "f" : true ,
        "g" : true ,
        "h" : true ,
        "i" : true ,
        "j" : true ,
        "k" : true ,
        "l" : true ,
        "m" : true ,
        "n" : true ,
        "o" : true ,
        "p" : true ,
        "q" : true ,
        "r" : true ,
        "s" : true ,
        "t" : true ,
        "a" : true
}

Preparation code output

var ar = [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, "a"] ; ar.indexOf("a"); var obj = { "b" : true , "c" : true , "d" : true , "e" : true , "f" : true , "g" : true , "h" : true , "i" : true , "j" : true , "k" : true , "l" : true , "m" : true , "n" : true , "o" : true , "p" : true , "q" : true , "r" : true , "s" : true , "t" : true , "a" : true }

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
ar.indexOf("a")
pending…
Object
obj["a"]
pending…

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

Compare results of other browsers

0 comments

Add a comment