API reference › @evolu/common › Object › isPlainObject
function isPlainObject(value: unknown): value is Record<string, unknown>;
Defined in: packages/common/src/Object.ts:36
Checks if a value is a plain object (e.g., created with {} or Object).
Accepts objects with Object.prototype and objects with a null prototype
created via Object.create(null). Rejects class instances and other built-in
objects because their prototype chain includes an application-specific or
built-in prototype before Object.prototype.
The prototype-chain check uses structure instead of prototype === Object.prototype so it also works for plain objects coming from another
JavaScript realm.
Example
isPlainObject({}); // true
isPlainObject(Object.create(null)); // true
isPlainObject(new Date()); // false
isPlainObject(new (class Example {})()); // false
isPlainObject([]); // false
isPlainObject(null); // false