Script Preparation code:
x
 
function isObject(o) {
  return Object.prototype.toString.call(o) === '[object Object]';
}
function isPlainObject(o) {
  var ctor,prot;
  if (isObject(o) === false) return false;
  // If has modified constructor
  ctor = o.constructor;
  if (ctor === undefined) return true;
  // If has modified prototype
  prot = ctor.prototype;
  if (isObject(prot) === false) return false;
  // If constructor does not have an Object-specific method
  if (prot.hasOwnProperty('isPrototypeOf') === false) {
    return false;
  }
  // Most likely a plain Object
  return true;
};
Tests:
  • isPlainObject

     
    const a = {a:1}
    isPlainObject(a)
  • typeof and null check

     
    const a = {a:1}
    a !== null && typeof a === 'object'
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    isPlainObject
    typeof and null check

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36
Chrome 100 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
isPlainObject 1550293.5 Ops/sec
typeof and null check 946768256.0 Ops/sec