hasOwnProperty vs in vs undefined (v41)

Revision 41 of this benchmark created by Yaniv Kessler 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

Revisions

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