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

Fill with given value!

Alternatives: fill, fill$.


function fill$(x, v, i, I)
// x: an array (updated!)
// v: value
// i: begin index [0]
// I: end index [|x|]
const xarray = require('extra-array');

var x = [1, 2, 3, 4];
xarray.fill$(x, 2);
// → [ 2, 2, 2, 2 ]

x;
// → [ 2, 2, 2, 2 ]

var x = [1, 2, 3, 4];
xarray.fill$(x, 2, 1);
// → [ 1, 2, 2, 2 ]

var x = [1, 2, 3, 4];
xarray.fill$(x, 2, 1, 3);
// → [ 1, 2, 2, 4 ]


References

Clone this wiki locally