isObject
isObject(
value):value is object
Defined in: packages/core/src/guards/is-object.ts:35
Check whether a value is a non-null object that is not an array.
A function never passes: typeof reports it as "function", not "object".
Everything else non-primitive does — a Date, a Map, a Promise, a class
instance, an Object.create(null) bag.
Reach for it when the next thing you do is read a property off the value and an array would take a different branch. It answers “is there an object here”, not “is this object a data bag”.
The family, from loosest to strictest:
isObject— any non-null, non-array object, whatever built it.isPojo— narrows toRecord<string, unknown>; rejects aDate, aMapand a class instance, whose prototype chain does not reachObject.prototype. Use it before merging, cloning or deep-comparing, where walking aDate’s own keys would silently drop its value.hasObjectPrototype— the same question asked of the own prototype only, soObject.create({})fails whereisPojopasses. Use it when the answer decides how a value is rebuilt, not just how it is read.
Parameters
Section titled “Parameters”unknown
The value to check
Returns
Section titled “Returns”value is object
True if the value is a non-array object
Example
Section titled “Example” isObject({}); // true isObject(new Date()); // true isObject([]); // false isObject(null); // false isObject(() => {}); // false ```;