diff --git a/isPlainObject.js b/isPlainObject.js index beba9ec21..34dcf9af8 100644 --- a/isPlainObject.js +++ b/isPlainObject.js @@ -1,15 +1,6 @@ import baseGetTag from './.internal/baseGetTag.js' import isObjectLike from './isObjectLike.js' -/** Used to resolve the decompiled source of functions. */ -const funcToString = Function.prototype.toString - -/** Used to check objects for own properties. */ -const hasOwnProperty = Object.prototype.hasOwnProperty - -/** Used to infer the `Object` constructor. */ -const objectCtorString = funcToString.call(Object) - /** * Checks if `value` is a plain object, that is, an object created by the * `Object` constructor or one with a `[[Prototype]]` of `null`. @@ -40,13 +31,14 @@ function isPlainObject(value) { if (!isObjectLike(value) || baseGetTag(value) != '[object Object]') { return false } - const proto = Object.getPrototypeOf(value) - if (proto === null) { + if (Object.getPrototypeOf(value) === null) { return true } - const Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor - return typeof Ctor == 'function' && Ctor instanceof Ctor && - funcToString.call(Ctor) == objectCtorString + let proto = value + while (Object.getPrototypeOf(proto) !== null) { + proto = Object.getPrototypeOf(proto) + } + return Object.getPrototypeOf(value) === proto } export default isPlainObject