array access versus object access

JavaScript performance comparison

Test case created

Preparation code

<script>
var a = [];
for (var i = 1000; i--; ) { a.push(i); }
var b = { a: 'aoue', b: 'baoelu', c: 1239012 }
var c = [a,b];

var array = [a,b,c];
var object = {a:a, b:b, c:c};
</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
array[0];
array[1];
array[2];
pending…
object
object.a
object.b
object.c
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