mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
32 lines
784 B
JavaScript
32 lines
784 B
JavaScript
define([], function() {
|
|
|
|
/** Used for native method references. */
|
|
var objectProto = Object.prototype;
|
|
|
|
/** Used to check objects for own properties. */
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
|
|
/**
|
|
* Checks if `key` exists as a direct property of `object` instead of an
|
|
* inherited property.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to inspect.
|
|
* @param {string} key The key to check.
|
|
* @returns {boolean} Returns `true` if `key` is a direct property, else `false`.
|
|
* @example
|
|
*
|
|
* var object = { 'a': 1, 'b': 2, 'c': 3 };
|
|
*
|
|
* _.has(object, 'b');
|
|
* // => true
|
|
*/
|
|
function has(object, key) {
|
|
return object ? hasOwnProperty.call(object, key) : false;
|
|
}
|
|
|
|
return has;
|
|
});
|