Key exists check (v47)

Revision 47 of this benchmark created on


Preparation HTML

<script>
  var data = Object.create(null);
  var out = {};
  var toCheck;
  var toCheckNotExists;
  
  for (var i = 0; i < 10000; i++) {
   var key = 'user ' + i;
   data[key] =  key + i;

   // toCheck is initialized here to prevent any optimizations for static values
   if ( i == 5000) {
     toCheck = key;
     toCheckNotExists = "not" + key;
   }
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
key in data
out[0] = toCheck in data;
out[1] = toCheckNotExists in data;
ready
data[key]
out[0] = data[toCheck] !== undefined;
out[1] = data[toCheckNotExists] !== undefined;
ready

Revisions

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