• Sets a value in a nested object or array based on the specified key.

    Parameters

    • target: unknown

      The target object or array.

    • key: string | number | string[]

      The key to set the value at using dot notation.

    • value: unknown

      The value to set.

    • overwrite: boolean = true

      Specifies whether to overwrite an existing value at the key.

    Returns unknown

    The modified target object or array.

    Example

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

Generated using TypeDoc