-
-
Notifications
You must be signed in to change notification settings - Fork 0
plain object
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isPlainObject<T extends Record<string, any>>(it: unknown): it is T;
Check if the given value is a plain object, which is an object that either has a
prototype of null
or Object.prototype
.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a plain object, false
otherwise.
Objects
import { isPlainObject } from "jsr:@nick/is/plain-object";
console.log(isPlainObject({})); // true
console.log(isPlainObject(new class {}())); // true
console.log(isPlainObject(new Object())); // true
console.log(isPlainObject([])); // false
console.log(isPlainObject(() => {})); // false
console.log(isPlainObject(null)); // false
console.log(isPlainObject(undefined)); // false
console.log(isPlainObject(1)); // false