Skip to content
Subhajit Sahu edited this page Dec 8, 2022 · 12 revisions

Set value at specified key.

Alternatives: set, set$.
Similar: set, setPath$.
Similar: get, set, swap, remove.


function set(x, k, v)
// x: an object
// k: key
// v: value
const object = require('extra-object');

var x = {a: 2, b: 4, c: 6, d: 8};
object.set(x, 'b', 40);
// → { a: 2, b: 40, c: 6, d: 8 }

object.set(x, 'd', 80);
// → { a: 2, b: 4, c: 6, d: 80 }


References

Clone this wiki locally