array vs obj (v9)

Revision 9 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var collectionObj = {};
  var collectionArr = [];
  var collectionStr = '';
  for (var i = 0; i < 1000; i++) {
   collectionObj["string" + i] = "doesn't matter";
   collectionArr.push("string" + i);
   collectionStr += "string" + i + "doesn't matter";
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
array
collectionObj.hasOwnProperty("string500");
ready
obj
jQuery.inArray("string500", collectionArr)
ready
str
collectionStr.indexOf("string500") > 0
ready
obj
!collectionObj["string500"]
ready

Revisions

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