array vs object access times

JavaScript performance comparison

Test case created by Andreas Goebel

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var arr = ['foo', true, 'bar', {}, 'baz'],
        obj = {0: 'foo', 1: true, 2: 'bar', 3: {}, 4:'baz'};
};
</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 access
arr[1] + arr[2];
pending…
object access
obj[1] + obj[2];
pending…

Compare results of other browsers

Revisions

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:

0 comments

Add a comment