hasOwnProperty alternatives (v5)

Revision 5 of this benchmark created on


Setup

var obj = { actions : "0" };

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
undefined
if (typeof obj.actions !== 'undefined') {
  return true;
}
ready
undefined cmp
if (obj.actions !== undefined) {
  return true;
}
ready
double boolean
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.