• Retrieves the value of a property from a given object using a key. If the key is not provided, it returns the target object itself.

    Parameters

    • target: unknown

      The target object to retrieve the value from.

    • Optional key: string | number | string[]

      The key in dot notation or path to the property.

    • Optional fallback: unknown

      The fallback value if the property is not found.

    Returns unknown

    The value of the property or the fallback value.

    Example

    const object = {users: {name: ['Taylor', 'Otwell']}};
    dataGet(object, 'users.name.0') // 'Taylor'

Generated using TypeDoc