Function getProperty

  • Returns the value resolved by a property path while preserving present undefined and null values.

    Unlike safeAccess, this function returns a present nullish property unchanged. A missing or invalid path returns undefined; use hasProperty when that result must be distinguished from a present undefined property. Array indexes require numeric keys through an exact array property-key path.

    Type Parameters

    • T extends object

      Root object type.

    • const P extends PropertyPath

      Property path type.

    Parameters

    • data: T

      Object to inspect.

    • path: P

      Dotted or exact property-key path.

    • Optionaloptions: { hasOwnOnly?: boolean }

      Property lookup options.

      • OptionalhasOwnOnly?: boolean

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

    Returns DeepAccess<T, P>

    The resolved property value, or undefined when the path cannot be resolved.

    If options.hasOwnOnly is not a boolean.