isPlainObject
Category
Export size
min 0.15 kB · gzip 0.13 kB
See also
Type guard for a plain object — one whose prototype is Object.prototype or null. Arrays, null, primitives and class instances (Date, RegExp, Map, bson ObjectId, ...) are all false.
ts
import { isPlainObject } from 'feathers-utils/helpers';Example
ts
import { isPlainObject } from 'feathers-utils/helpers'
isPlainObject({}) // => true
isPlainObject(Object.create(null)) // => true
isPlainObject([]) // => false
isPlainObject(new Date()) // => falseType declaration
Show Type Declarations
ts
/**
* Type guard for a plain object — one whose prototype is `Object.prototype` or
* `null`. Arrays, `null`, primitives and class instances (`Date`, `RegExp`,
* `Map`, bson `ObjectId`, ...) are all `false`.
*
* @example
* ```ts
*
*
* isPlainObject({}) // => true
* isPlainObject(Object.create(null)) // => true
* isPlainObject([]) // => false
* isPlainObject(new Date()) // => false
* ```
*
* @see https://utils.feathersjs.com/helpers/is-plain-object.html
*/
export declare const isPlainObject: (
value: unknown,
) => value is Record<string, any>| Argument | Type | Description |
|---|---|---|
| value | unknown |
Coming from lodash
A drop-in for _.isPlainObject. The one difference: an object from another realm (an iframe, vm.runInNewContext) has a different Object.prototype and is false here.
