@mogeko/is-plain-object
v0.0.3
Published
Returns true if an object was created by the `Object` constructor, or Object.create(null)
Downloads
3
Readme
is-plain-object
Returns true if an object was created by the
Object
constructor, or Object.create(null).
This project originated from is-plain-object (released under MIT license). I reimplemented it by TypeScript.
Usage
With ES modules:
import { isPlainObject } from "is-plain-object";
true when created by the Object
constructor, or Object.create(null)
.
isPlainObject(Object.create({})); // => true
isPlainObject(Object.create(Object.prototype)); // => true
isPlainObject({ foo: "bar" }); // => true
isPlainObject({}); // => true
isPlainObject(Object.create(null)); // => true
false when not created by the Object
constructor.
isPlainObject(["foo", "bar"]); // => false
isPlainObject([]); // => false
isPlainObject(new Foo()); // => false
License
The original project is released under the MIT License.
The code in this project is released under the MIT License.