hasOwnProperty vs in vs undefined (v33)

Revision 33 of this benchmark created by Ky6uk on


Setup

var obj = {
      action: true
    };

Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty
if (obj.hasOwnProperty("actions")) {
  return true;
}
ready
in
if ("actions" in obj) {
  return true;
}
ready
bool (dynamic)
if (obj["actions"]) {
  return true;
}
ready
bool (coherency check)
if (obj.actions) {
  return true;
}
ready
hasOwnProperty (2)
if (obj.hasOwnProperty('test')) {
  return false;
}
ready
in (2)
if ("test" in obj) {
  return false;
}
ready
bool (dynamic) (2)
if (obj["test"]) {
  return false;
}
ready
bool (coherency check) (2)
if (obj.test) {
  return false;
}
ready

Revisions

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