Array index vs object index (v2)

Revision 2 of this benchmark created by bigbossSNK on


Description

Tests speed of item lookup in an array vs an object.

Preparation HTML

<script>
  var a = ["item1", "item2", "item3"];
  var b = {
   label1: "item1",
   label2: "item2",
   label3: "item3"
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Array index
var lookup = a[2];
ready
Object Label
var lookup = b.label3;
ready
Object Label (bracket)
var lookup = b["label3"];
ready
Object Index
var lookup = b[2];
ready

Revisions

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

  • Revision 1: published by Brett on
  • Revision 2: published by bigbossSNK on