1 | # is-plain-object [](https://www.npmjs.com/package/is-plain-object) [](https://npmjs.org/package/is-plain-object) [](https://npmjs.org/package/is-plain-object) [](https://travis-ci.org/jonschlinkert/is-plain-object)
|
---|
2 |
|
---|
3 | > Returns true if an object was created by the `Object` constructor, or Object.create(null).
|
---|
4 |
|
---|
5 | Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
---|
6 |
|
---|
7 | ## Install
|
---|
8 |
|
---|
9 | Install with [npm](https://www.npmjs.com/):
|
---|
10 |
|
---|
11 | ```sh
|
---|
12 | $ npm install --save is-plain-object
|
---|
13 | ```
|
---|
14 |
|
---|
15 | Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to check if the value is an object and not an array or null.
|
---|
16 |
|
---|
17 | ## Usage
|
---|
18 |
|
---|
19 | with es modules
|
---|
20 | ```js
|
---|
21 | import { isPlainObject } from 'is-plain-object';
|
---|
22 | ```
|
---|
23 |
|
---|
24 | or with commonjs
|
---|
25 | ```js
|
---|
26 | const { isPlainObject } = require('is-plain-object');
|
---|
27 | ```
|
---|
28 |
|
---|
29 | **true** when created by the `Object` constructor, or Object.create(null).
|
---|
30 |
|
---|
31 | ```js
|
---|
32 | isPlainObject(Object.create({}));
|
---|
33 | //=> true
|
---|
34 | isPlainObject(Object.create(Object.prototype));
|
---|
35 | //=> true
|
---|
36 | isPlainObject({foo: 'bar'});
|
---|
37 | //=> true
|
---|
38 | isPlainObject({});
|
---|
39 | //=> true
|
---|
40 | isPlainObject(null);
|
---|
41 | //=> true
|
---|
42 | ```
|
---|
43 |
|
---|
44 | **false** when not created by the `Object` constructor.
|
---|
45 |
|
---|
46 | ```js
|
---|
47 | isPlainObject(1);
|
---|
48 | //=> false
|
---|
49 | isPlainObject(['foo', 'bar']);
|
---|
50 | //=> false
|
---|
51 | isPlainObject([]);
|
---|
52 | //=> false
|
---|
53 | isPlainObject(new Foo);
|
---|
54 | //=> false
|
---|
55 | isPlainObject(Object.create(null));
|
---|
56 | //=> false
|
---|
57 | ```
|
---|
58 |
|
---|
59 | ## About
|
---|
60 |
|
---|
61 | <details>
|
---|
62 | <summary><strong>Contributing</strong></summary>
|
---|
63 |
|
---|
64 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
---|
65 |
|
---|
66 | </details>
|
---|
67 |
|
---|
68 | <details>
|
---|
69 | <summary><strong>Running Tests</strong></summary>
|
---|
70 |
|
---|
71 | Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
---|
72 |
|
---|
73 | ```sh
|
---|
74 | $ npm install && npm test
|
---|
75 | ```
|
---|
76 |
|
---|
77 | </details>
|
---|
78 |
|
---|
79 | <details>
|
---|
80 | <summary><strong>Building docs</strong></summary>
|
---|
81 |
|
---|
82 | _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
---|
83 |
|
---|
84 | To generate the readme, run the following command:
|
---|
85 |
|
---|
86 | ```sh
|
---|
87 | $ npm install -g verbose/verb#dev verb-generate-readme && verb
|
---|
88 | ```
|
---|
89 |
|
---|
90 | </details>
|
---|
91 |
|
---|
92 | ### Related projects
|
---|
93 |
|
---|
94 | You might also be interested in these projects:
|
---|
95 |
|
---|
96 | * [is-number](https://www.npmjs.com/package/is-number): Returns true if a number or string value is a finite number. Useful for regex… [more](https://github.com/jonschlinkert/is-number) | [homepage](https://github.com/jonschlinkert/is-number "Returns true if a number or string value is a finite number. Useful for regex matches, parsing, user input, etc.")
|
---|
97 | * [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
|
---|
98 | * [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
|
---|
99 |
|
---|
100 | ### Contributors
|
---|
101 |
|
---|
102 | | **Commits** | **Contributor** |
|
---|
103 | | --- | --- |
|
---|
104 | | 19 | [jonschlinkert](https://github.com/jonschlinkert) |
|
---|
105 | | 6 | [TrySound](https://github.com/TrySound) |
|
---|
106 | | 6 | [stevenvachon](https://github.com/stevenvachon) |
|
---|
107 | | 3 | [onokumus](https://github.com/onokumus) |
|
---|
108 | | 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
---|
109 |
|
---|
110 | ### Author
|
---|
111 |
|
---|
112 | **Jon Schlinkert**
|
---|
113 |
|
---|
114 | * [GitHub Profile](https://github.com/jonschlinkert)
|
---|
115 | * [Twitter Profile](https://twitter.com/jonschlinkert)
|
---|
116 | * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
---|
117 |
|
---|
118 | ### License
|
---|
119 |
|
---|
120 | Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
|
---|
121 | Released under the [MIT License](LICENSE).
|
---|
122 |
|
---|
123 | ***
|
---|
124 |
|
---|
125 | _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 28, 2019._
|
---|