hasOwnProperty vs in vs undefined (v59)

Revision 59 of this benchmark created by Ingvar Stepanyan on


Setup

var Iobj = Object.create(null);
    Iobj.SUPPORT_ACTIONS = 0x1;
    
    var obj = Object.create(null);
    obj.actions = true;
    obj.support = Iobj.SUPPORT_ACTIONS;
    
    var undefined;
    var hasOwnProperty = Object.prototype.hasOwnProperty;

Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty
if (hasOwnProperty.call(obj, "actions")) {
  return true;
}
ready
in
if ("actions" in obj) {
  return true;
}
ready
undefined
if (typeof obj.actions !== 'undefined') {
  return true;
}
ready
undefined cmp
if (obj.actions !== undefined) {
  return true;
}
ready
binary indicator
if (obj.support & Iobj.SUPPORT_ACTIONS) return true;
ready
undefined cmp (dynamic)
if (obj['actions'] !== undefined) {
  return true;
}
ready
undefined dynamic
if (typeof obj['actions'] !== 'undefined') {
  return true;
}
ready
void 0
if (obj.actions !== void 0) {
  return true;
}
ready
if
if (obj.actions) {
  return true;
}
ready

Revisions

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