baseHas.js 888 B

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