1 var baseGetTag = require('./_baseGetTag'),
2 getPrototype = require('./_getPrototype'),
3 isObjectLike = require('./isObjectLike');
5 /** `Object#toString` result references. */
6 var objectTag = '[object Object]';
8 /** Used for built-in method references. */
9 var funcProto = Function.prototype,
10 objectProto = Object.prototype;
12 /** Used to resolve the decompiled source of functions. */
13 var funcToString = funcProto.toString;
15 /** Used to check objects for own properties. */
16 var hasOwnProperty = objectProto.hasOwnProperty;
18 /** Used to infer the `Object` constructor. */
19 var objectCtorString = funcToString.call(Object);
22 * Checks if `value` is a plain object, that is, an object created by the
23 * `Object` constructor or one with a `[[Prototype]]` of `null`.
29 * @param {*} value The value to check.
30 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
37 * _.isPlainObject(new Foo);
40 * _.isPlainObject([1, 2, 3]);
43 * _.isPlainObject({ 'x': 0, 'y': 0 });
46 * _.isPlainObject(Object.create(null));
49 function isPlainObject(value) {
50 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
53 var proto = getPrototype(value);
57 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
58 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
59 funcToString.call(Ctor) == objectCtorString;
62 module.exports = isPlainObject;