Test name | Executions per second |
---|---|
Lodash isPlainObject | 532042.6 Ops/sec |
JS Type Check | 1146496.2 Ops/sec |
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.20/lodash.min.js"></script>
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))
)
}
_.isPlainObject(sampleObject);
_.isPlainObject(sampleObject2);
_.isPlainObject(sampleObject3);
_.isPlainObject(sampleObject4);
_.isPlainObject(sampleObject5);
isObject(sampleObject);
isObject(sampleObject2);
isObject(sampleObject3);
isObject(sampleObject4);
isObject(sampleObject5);