@extra-array/copy-within
v2.10.19
Published
Copies part of array within.
Downloads
73
Maintainers
Readme
Copies part of array within. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
Alternatives: copyWithin, copyWithin$. Similar: copy, copyWithin, moveWithin.
This is part of package extra-array.
array.copyWithin(x, [j], [i], [I]);
// x: an array
// j: write index (0)
// i: read start index (0)
// I: read end index (X)
const array = require("extra-array");
var x = [1, 2, 3, 4, 5];
array.copyWithin(x, 3);
// [ 1, 2, 3, 1, 2 ]
array.copyWithin(x, 3, 1);
// [ 1, 2, 3, 2, 3 ]
array.copyWithin(x, 3, 1, 2);
// [ 1, 2, 3, 2, 5 ]