Skip to content

setAtPath

setAtPath(root, path, value): void

Defined in: packages/core/src/object/set-at-path.ts:24

Mutates root by setting the value at path.

Creates intermediate plain objects or arrays as needed based on the type of the next key (number → array, string → object). Existing null or undefined intermediates are replaced.

A path containing __proto__, constructor or prototype is refused outright and nothing is written, because walking one reaches a prototype shared with every other object. The refusal is silent, like the one for a non-numeric index into an array.

unknown[] | Record<string, unknown>

The root object/array to mutate

PropertyPath

The path to traverse

unknown

The value to set at the path

void