1 var isHostObject = require('./_isHostObject'),
2 isObjectLike = require('./isObjectLike');
4 /** `Object#toString` result references. */
5 var objectTag = '[object Object]';
7 /** Used for built-in method references. */
8 var objectProto = Object.prototype;
10 /** Used to resolve the decompiled source of functions. */
11 var funcToString = Function.prototype.toString;
13 /** Used to infer the `Object` constructor. */
14 var objectCtorString = funcToString.call(Object);
17 * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
20 var objectToString = objectProto.toString;
22 /** Built-in value references. */
23 var getPrototypeOf = Object.getPrototypeOf;
26 * Checks if `value` is a plain object, that is, an object created by the
27 * `Object` constructor or one with a `[[Prototype]]` of `null`.
32 * @param {*} value The value to check.
33 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
40 * _.isPlainObject(new Foo);
43 * _.isPlainObject([1, 2, 3]);
46 * _.isPlainObject({ 'x': 0, 'y': 0 });
49 * _.isPlainObject(Object.create(null));
52 function isPlainObject(value) {
53 if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) {
56 var proto = objectProto;
57 if (typeof value.constructor == 'function') {
58 proto = getPrototypeOf(value);
63 var Ctor = proto.constructor;
64 return (typeof Ctor == 'function' &&
65 Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
68 module.exports = isPlainObject;