Skip to content

Support array push notation in _.set #1315

Closed
@DylanPiercey

Description

@DylanPiercey

Currently when using set it will support the computed property notation so that I can go

_.set({}, "a[b][c]", 1)
// -> { a: { b: { c: 1 } } }

This works great for turning a urlencoded form's input name into an object however it would be nice if the "push" notation was also valid (currently it does nothing).

By that I mean:

_.set({ a: [1] }, "a[]", 2)
// -> { a: [1, 2] }

// currently -> { a: 2 }

Is this possible? It would be pretty handy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions