Object hasOwnProperty vs Array indexOf (v13)

Revision 13 of this benchmark created by David on


Preparation HTML

<script>
  var timing = {id: 5, time: 134.56};

  var object = {};
  var array = [];
  var test = 'pepe9999';

  var i;  
  for (i = 0; i < 1000; i++) {
   object['pepe'+i] = timing;
   array.push(timing);
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
object.hasOwnProperty
object.hasOwnProperty(test)
ready
test in object
(test) in object
ready
typeof
typeof object[test] === "undefined";
 
ready
sin comillas
object[test] === undefined;
 
ready

Revisions

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