hasOwnProperty vs in vs undefined (v9)

Revision 9 of this benchmark created on


Setup

var Iobj = {
      SUPPORT_ACTIONS: 0x1
    };
    var obj = {
      actions: true,
      support: Iobj.SUPPORT_ACTIONS
    };
    var undefined, hasOwnProperty = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty, obj, 'actions');

Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty
if (hasOwnProperty()) {
  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

Revisions

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