Home

function: hasPathIn


hasPathIn(object: Object, path: Array, string): boolean

Checks if `path` is a direct property of `object`.

Example(s):

const object = { 'a': { 'b': 2 } }
const other = create({ 'a': create({ 'b': 2 }) })

hasPathIn(object, 'a.b')
// => true

hasPathIn(object, ['a', 'b'])
// => true

Params:

Name Type Attribute Description
object The object to query.
path The path to check.

Returns:

boolean

  {
    "comment": "/**\r\n * Checks if `path` is a direct property of `object`.\r\n *\r\n * @since 5.0.0\r\n * @category Object\r\n * @param {Object} object The object to query.\r\n * @param {Array|string} path The path to check.\r\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\r\n * @see has, hasIn hasPath\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 * hasPathIn(object, 'a.b')\r\n * // => true\r\n *\r\n * hasPathIn(object, ['a', 'b'])\r\n * // => true\r\n */",
    "meta": {
        "range": [
            734,
            1284
        ],
        "filename": "hasPathIn.js",
        "lineno": 27,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100003476",
            "name": "hasPathIn",
            "type": "FunctionDeclaration",
            "paramnames": [
                "object",
                "path"
            ]
        },
        "vars": {
            "path": "hasPathIn~path",
            "index": "hasPathIn~index",
            "length": "hasPathIn~length",
            "result": "hasPathIn~result",
            "key": "hasPathIn~key",
            "object": "hasPathIn~object"
        }
    },
    "description": "Checks if `path` is a direct property of `object`.",
    "since": "5.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Object",
            "value": "Object"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Object"
                ]
            },
            "description": "The object to query.",
            "name": "object"
        },
        {
            "type": {
                "names": [
                    "Array",
                    "string"
                ]
            },
            "description": "The path to check.",
            "name": "path"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "boolean"
                ]
            },
            "description": "Returns `true` if `path` exists, else `false`."
        }
    ],
    "see": [
        "has, hasIn hasPath"
    ],
    "examples": [
        "const object = { 'a': { 'b': 2 } }\rconst other = create({ 'a': create({ 'b': 2 }) })\r\rhasPathIn(object, 'a.b')\r// => true\r\rhasPathIn(object, ['a', 'b'])\r// => true"
    ],
    "name": "hasPathIn",
    "longname": "hasPathIn",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000361",
    "___s": true,
    "filepath": "hasPathIn.js"
}