@extra-array/copy-within-update
Version:
Copies part of array within.
60 lines (44 loc) • 1.64 kB
Markdown
Copies part of array within.
[:package:](https://www.npmjs.com/package/@extra-array/copy-within-update)
[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
[:running:](https://npm.runkit.com/@extra-array/copy-within-update)
[:vhs:](https://asciinema.org/a/332031)
[:moon:](https://www.npmjs.com/package/@extra-array/copy-within-update.min)
[:scroll:](https://unpkg.com/@extra-array/copy-within-update/)
[:newspaper:](https://nodef.github.io/extra-array/)
[:blue_book:](https://github.com/nodef/extra-array/wiki/)
> Alternatives: [copyWithin], [copyWithin$].<br>
> Similar: [copy], [copyWithin], [moveWithin].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
<br>
```javascript
array.copyWithin$(x, [j], [i], [I]);
// x: an array (updated)
// j: write index (0)
// i: read start index (0)
// I: read end index (X)
// → x
```
```javascript
const array = require("extra-array");
var x = [1, 2, 3, 4, 5];
array.copyWithin$(x, 3);
// [ 1, 2, 3, 1, 2 ]
x;
// [ 1, 2, 3, 1, 2 ]
var x = [1, 2, 3, 4, 5];
array.copyWithin$(x, 3, 1);
// [ 1, 2, 3, 2, 3 ]
var x = [1, 2, 3, 4, 5];
array.copyWithin$(x, 3, 1, 2);
// [ 1, 2, 3, 2, 5 ]
```
<br>
<br>
## References
- [Array.prototype.copyWithin: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
[copyWithin]: https://github.com/nodef/extra-array/wiki/copyWithin
[copyWithin$]: https://github.com/nodef/extra-array/wiki/copyWithin$
[copy]: https://github.com/nodef/extra-array/wiki/copy
[moveWithin]: https://github.com/nodef/extra-array/wiki/moveWithin