Files
lodash/src/hasIn.ts
2023-09-16 14:47:50 -07:00

25 lines
557 B
TypeScript

/**
* Checks if `path` is a direct or inherited property of `object`.
*
* @since 4.0.0
* @category Object
* @param {Object} object The object to query.
* @param {string} key The key to check.
* @returns {boolean} Returns `true` if `key` exists, else `false`.
* @see has, hasPath, hasPathIn
* @example
*
* const object = create({ 'a': create({ 'b': 2 }) })
*
* hasIn(object, 'a')
* // => true
*
* hasIn(object, 'b')
* // => false
*/
function hasIn(object, key) {
return object != null && key in Object(object);
}
export default hasIn;