setIn()

Returns a copy of the collection with the value at the key path set to the provided value.

setIn<C>(collection: C, keyPath: Iterable<unknown>, value: unknown): C

Discussion

A functional alternative to collection.setIn(keypath) which will also work with plain Objects and Arrays.

const { setIn } = require('immutable') const original = { x: { y: { z: 123 }}} setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} console.log(original) // { x: { y: { z: 123 }}}run it
This documentation is generated from immutable.d.ts. Pull requests and Issues welcome.