Mutate a Deeply Nested Object Property Using a Dot-Notation String Path

Implement a set(obj, path, value) function that accepts an object, a dot/bracket-notation string path (e.g., 'a.b[2].c'), and a value, then writes that value at the specified location — creating intermediate objects or arrays as needed if they don't exist. This is the write counterpart to the get utility and mirrors lodash's _.set(). It's critical for immutable state update libraries, form state managers, and deep config patching tools.

Examples
Input: []
Output:
Hints

Mutate a Deeply Nested Object Property Using a Dot-Notation String Path

Implement a set(obj, path, value) function that accepts an object, a dot/bracket-notation string path (e.g., 'a.b[2].c'), and a value, then writes that value at the specified location — creating intermediate objects or arrays as needed if they don't exist. This is the write counterpart to the get utility and mirrors lodash's _.set(). It's critical for immutable state update libraries, form state managers, and deep config patching tools.