Function hasProperty

  • Determines whether an property path exists on an object.

    Traversal aborts immediately when a property is missing, an intermediate value cannot be traversed, or an invalid array index is encountered. Properties whose values are undefined or null are considered present. The terminal property value is not read, so a getter at the final segment is not invoked merely to test existence.

    Array indexes may only be accessed by number through the array property-key form.

    Parameters

    • data: object

      An object to inspect.

    • path: PropertyPath

      A dotted string path or an array of exact string, number, or symbol property keys.

    • Optionaloptions: { hasOwnOnly?: boolean }

      Property lookup options.

      • OptionalhasOwnOnly?: boolean

        Whether every path segment must be an own property; default: false.

    Returns boolean

    Whether the complete property path exists.

    If options.hasOwnOnly is not a boolean.