Skip to content
Subhajit Sahu edited this page May 3, 2023 · 27 revisions

Set value at index!

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


function set$(x, i, v)
// x: an array (updated!)
// i: index
// v: value
const xarray = require('extra-array');

var x = [2, 4, 6, 8];
xarray.set$(x, 1, 40);
// → [ 2, 40, 6, 8 ]

x;
// → [ 2, 40, 6, 8 ]

var x = [2, 4, 6, 8];
xarray.set$(x, 3, 80);
// → [ 2, 4, 6, 80 ]


References

Clone this wiki locally