mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
25 lines
553 B
JavaScript
25 lines
553 B
JavaScript
/**
|
|
* 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
|