obj vs array

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var ar = [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, "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
    }
};
</script>

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
"a" in obj
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