Files
lodash/hasIn.js
2017-01-10 01:46:24 -08:00

33 lines
733 B
JavaScript

import baseHasIn from './.internal/baseHasIn.js';
import hasPath from './.internal/hasPath.js';
/**
* 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 {Array|string} path The path to check.
* @returns {boolean} Returns `true` if `path` exists, else `false`.
* @example
*
* const object = create({ 'a': create({ 'b': 2 }) });
*
* hasIn(object, 'a');
* // => true
*
* hasIn(object, 'a.b');
* // => true
*
* hasIn(object, ['a', 'b']);
* // => true
*
* hasIn(object, 'b');
* // => false
*/
function hasIn(object, path) {
return object != null && hasPath(object, path, baseHasIn);
}
export default hasIn;