Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36
Chrome 88
Mac OS X 11.2.0
Desktop
4 years ago
Test name Executions per second
Lodash isPlainObject 556745.5 Ops/sec
JS Type Check 1347122.6 Ops/sec
HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.20/lodash.min.js"></script>
Script Preparation code:
x
 
var sampleObject = {
        "id": "0001",
        "type": "donut",
        "name": "Cake",
        "ppu": 0.55
    };
var sampleObject2 = Object.create(null);
var sampleObject3 = null;
var sampleObject4 = 100;
class Foo {
  constructor() {
    this.a = 1;
  }
}
var sampleObject5 = new Foo();
function isObject(any) {
return
(
        any != null &&
        (any.constructor === Object ||
            (typeof any === 'object' && Object.getPrototypeOf(any) === null))
    )
}
Tests:
  • Lodash isPlainObject

     
    _.isPlainObject(sampleObject);
    _.isPlainObject(sampleObject2);
    _.isPlainObject(sampleObject3);
    _.isPlainObject(sampleObject4);
    _.isPlainObject(sampleObject5);
  • JS Type Check

     
    isObject(sampleObject);
    isObject(sampleObject2);
    isObject(sampleObject3);
    isObject(sampleObject4);
    isObject(sampleObject5);