hasOwnProperty vs in vs undefined (v49)

Revision 49 of this benchmark created on


Description

A variant of http://jsperf.com/hasownproperty-vs-in-vs-undefined/12 just without the "var undefined" in the test code. This changes the picture for all the "undefined" dependent tests.

Setup

var Iobj = {
      SUPPORT_ACTIONS: 0x1
    };
    var obj = {
      actions: true,
      support: Iobj.SUPPORT_ACTIONS
    };
    var foo = "actions";

Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty
if (obj.hasOwnProperty("actions")) {
  return true;
}
ready
!hasOwnProperty
if (!obj.hasOwnProperty("actions")) {
  return true;
}
 
ready
truthy
if (obj.actions) {
  return true;
}
ready
falsey
if (!obj.actions) {
  return true;
}
ready
falsey dynamic
if (!obj["actions"]) {
  return true;
}
 
ready
double!!
return !!obj.actions
ready

Revisions

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