is-plain-obj
- Version 4.1.0
- Published
- 4.08 kB
- No dependencies
- MIT license
Install
npm i is-plain-obj
yarn add is-plain-obj
pnpm add is-plain-obj
Overview
Check if a value is a plain object
Index
Functions
Functions
function isPlainObject
isPlainObject: <Value>(value: unknown) => value is Record<PropertyKey, Value>;
Check if a value is a plain object.
An object is plain if it's created by either
{}
,new Object()
, orObject.create(null)
.Example 1
import isPlainObject from 'is-plain-obj';import {runInNewContext} from 'node:vm';isPlainObject({foo: 'bar'});//=> trueisPlainObject(new Object());//=> trueisPlainObject(Object.create(null));//=> true// This works across realmsisPlainObject(runInNewContext('({})'));//=> trueisPlainObject([1, 2, 3]);//=> falseclass Unicorn {}isPlainObject(new Unicorn());//=> falseisPlainObject(Math);//=> false
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (3)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/is-plain-obj
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/is-plain-obj)
- HTML<a href="https://www.jsdocs.io/package/is-plain-obj"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5188 ms. - Missing or incorrect documentation? Open an issue for this package.