hasOwnProperty vs in vs undefined (v43)

Revision 43 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
    };

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
binary indicator
if (obj.support & Iobj.SUPPORT_ACTIONS) return true;
ready
undefined cmp (dynamic)
if (obj['actions'] !== undefined) {
  return true;
}
ready
undefined dynamic
if (typeof obj['actions'] !== 'undefined') {
  return true;
}
ready
not
if (obj.actions) {
  return true;
}
ready
null
if (obj.actions != null) {
  return true;
}
ready
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.