hasOwnProperty vs in vs undefined (v66)

Revision 66 of this benchmark created by Drew on


Setup

var obj = {
       actions : ['foo', 'foo2', 'bar']
    };

Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty
if (obj.actions.hasOwnProperty("foo")) {
      return true;
}
ready
in
if ("foo" in obj.actions) {
      return true;
}
ready
undefined
if (typeof obj.actions.foo !== 'undefined') {
      return true;
}
ready
!= null
if (obj.actions.foo != null) {
      return true;
}
ready

Revisions

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