UNPKG

852 BJavaScriptView Raw
1import getPrototype from './_getPrototype';
2
3/** Used for built-in method references. */
4var objectProto = Object.prototype;
5
6/** Used to check objects for own properties. */
7var hasOwnProperty = objectProto.hasOwnProperty;
8
9/**
10 * The base implementation of `_.has` without support for deep paths.
11 *
12 * @private
13 * @param {Object} object The object to query.
14 * @param {Array|string} key The key to check.
15 * @returns {boolean} Returns `true` if `key` exists, else `false`.
16 */
17function baseHas(object, key) {
18 // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
19 // that are composed entirely of index properties, return `false` for
20 // `hasOwnProperty` checks of them.
21 return hasOwnProperty.call(object, key) ||
22 (typeof object == 'object' && key in object && getPrototype(object) === null);
23}
24
25export default baseHas;