Function hasPath

  • Checks if path is a direct property of object.

    Parameters

    • object: any

      The object to query.

    • path: PropertyPath

      The path to check.

    Returns boolean

    Returns true if path exists, else false.

    5.0.0

    has, hasIn, hasPathIn

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

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

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