Object hasOwnProperty vs Array indexOf (v8)

Revision 8 of this benchmark created on


Preparation HTML

<script>
  var object = {},
      array = [],
      i, test = 1001;
  
  for (i = 0; i < 1000; i++) {
   object['something' + i] = true;
   array.push('something' + i);
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
object.hasOwnProperty
object.hasOwnProperty('something' + test)
ready
array.indexOf
array.indexOf('something' + test) !== -1
ready

Revisions

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