set - nodef/extra-lists GitHub Wiki

Set value at key.

Similar: get, set, remove.

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

var x = ['a', 'b', 'c', 'd'], [2, 4, 6, 8](/nodef/extra-lists/wiki/'a',-'b',-'c',-'d'],-[2,-4,-6,-8);
xlists.set(x, 'b', 40);
// → [ [ 'a', 'b', 'c', 'd' ], [ 2, 40, 6, 8 ] ]

xlists.set(x, 'd', 80);
// → [ [ 'a', 'b', 'c', 'd' ], [ 2, 4, 6, 80 ] ]

References