javascript associative vs non-associative arrays

JavaScript performance comparison

Revision 22 of this test case created

Preparation code

<script>
  var arr = [];
  var asc = {};

  arr[0] = 0;
  arr[1] = 1;
  arr[2] = 2;

  asc.a = 0;
  asc.b = 1;
  asc.c = 2;
</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
Object access with numbers
asc.i0;
asc.i1;
asc.i2;
pending…
Object Access without numbers
asd.a;
asd.b;
asd.c;
pending…
Associative Array with numbers
ase['i0'];
ase['i1'];
ase['i2'];
pending…
Associative Array without numbers
asf['a'];
asf['b'];
asf['c'];
pending…
Array access
arr[0];
arr[1];
arr[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