Skip to content

resize$

Subhajit Sahu edited this page May 3, 2023 · 1 revision

Resize an array to given length!


function resize$(x, n, vd)
// x:  an array
// n:  new length
// vd: default value

const xarray = require('extra-array');

var x = [1, 2, 3, 4, 5];
xarray.resize$(x, 3, 0);
console.log(x);
// → [ 1, 2, 3 ]

var x = [1, 2, 3, 4, 5];
xarray.resize$(x, 7, 0);
console.log(x);
// → [ 1, 2, 3, 4, 5, 0, 0 ]


References

Clone this wiki locally