Checks if `key` is a direct property of `object`.
const object = { 'a': { 'b': 2 } }
const other = create({ 'a': create({ 'b': 2 }) })
has(object, 'a')
// => true
has(other, 'a')
// => false
| Name | Type | Attribute | Description |
|---|---|---|---|
| object | The object to query. | ||
| key | The key to check. |
{
"comment": "/**\r\n * Checks if `key` is a direct property of `object`.\r\n *\r\n * @since 0.1.0\r\n * @category Object\r\n * @param {Object} object The object to query.\r\n * @param {string} key The key to check.\r\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\r\n * @see hasIn, hasPath, hasPathIn\r\n * @example\r\n *\r\n * const object = { 'a': { 'b': 2 } }\r\n * const other = create({ 'a': create({ 'b': 2 }) })\r\n *\r\n * has(object, 'a')\r\n * // => true\r\n *\r\n * has(other, 'a')\r\n * // => false\r\n */",
"meta": {
"range": [
598,
689
],
"filename": "has.js",
"lineno": 24,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100003281",
"name": "has",
"type": "FunctionDeclaration",
"paramnames": [
"object",
"key"
]
}
},
"description": "Checks if `key` is a direct property of `object`.",
"since": "0.1.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Object",
"value": "Object"
}
],
"params": [
{
"type": {
"names": [
"Object"
]
},
"description": "The object to query.",
"name": "object"
},
{
"type": {
"names": [
"string"
]
},
"description": "The key to check.",
"name": "key"
}
],
"returns": [
{
"type": {
"names": [
"boolean"
]
},
"description": "Returns `true` if `key` exists, else `false`."
}
],
"see": [
"hasIn, hasPath, hasPathIn"
],
"examples": [
"const object = { 'a': { 'b': 2 } }\rconst other = create({ 'a': create({ 'b': 2 }) })\r\rhas(object, 'a')\r// => true\r\rhas(other, 'a')\r// => false"
],
"name": "has",
"longname": "has",
"kind": "function",
"scope": "global",
"___id": "T000002R000346",
"___s": true,
"filepath": "has.js"
}