isPlainObject
Using
This function determines whether the given value is a plain object.
- Returns
true
if the value is a regular object (created via{}
,new Object()
,Object.create(null)
). - Returns
false
for arrays, functions, special objects (Date
,Map
, etc.), and non-object types.
Demo - use JSON
isPlainObject( )
false
Arguments
Argument | Type | Description | Example |
---|---|---|---|
value | unknown | Can be any type | "text" 2 undefined |
Returns
boolean
— true
if value is a plain object, false
otherwise
Examples
isPlainObject({});
// true
isPlainObject({ key: 'value' });
// true
isPlainObject(Object.create(null));
// true
isPlainObject(null);
// false
isPlainObject(Object.create({ value: 'text' }));
// false
isPlainObject(42);
// false
isPlainObject([]);
// false
isPlainObject(new Date());
// false
isPlainObject(() => {});
// false