hasOwnProperty vs in vs undefined (v16)

Revision 16 of this benchmark created on


Setup

var Iobj = {
      SUPPORT_ACTIONS: 0x1
    };
    var obj = {
      actions: 'action1 action2 action3',
      support: Iobj.SUPPORT_ACTIONS
    };

Test runner

Ready to run.

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

Revisions

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