hasOwnProperty vs in vs undefined (v69)

Revision 69 of this benchmark created on


Setup

var Iobj = {
      SUPPORT_ACTIONS: 0x1
    };
    var obj = Object.create(null)
    obj.actions = true;
    obj.support = Iobj.SUPPORT_ACTIONS;
    obj.q = 3;
    obj.s = 4;
    delete obj.s;
    obj.qze = 9;
    obj.qvxre = 9;
    obj.qrxte = 9;
    obj.qre = 9;
    obj.qte = 9;
    obj.qrte = 9;
    obj.qetx = 9;
    obj.qetvx = 9;
    obj.qevt = 9;
    obj.qe14 = 9;
    obj.qer = 9;
    obj.qet = 9;
    obj.qezfe = 9;
    obj.qefea = 9;
    obj.qeaf = 9;
    obj.qeaa = 9;
    obj.qeqa = 9;
    var undefined;

Test runner

Ready to run.

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

Revisions

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