UNPKG

@extra-array/slice

Version:
51 lines (36 loc) 1.25 kB
Gets a part of array. [:package:](https://www.npmjs.com/package/@extra-array/slice) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/slice) [:vhs:](https://asciinema.org/a/332131) [:moon:](https://www.npmjs.com/package/@extra-array/slice.min) [:scroll:](https://unpkg.com/@extra-array/slice/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [slice], [slice$]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.slice(x, [i], [I]); // x: an array // i: start index (0) // I: end index (X) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4, 5]; array.slice(x, 2); // [ 3, 4, 5 ] array.slice(x, 2, 4); // [ 3, 4 ] array.slice(x, -3, -1); // [ 3, 4 ] ``` <br> <br> ## References - [Array.prototype.slice: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) - [_.slice: lodash](https://lodash.com/docs/4.17.15#slice) [slice]: https://github.com/nodef/extra-array/wiki/slice [slice$]: https://github.com/nodef/extra-array/wiki/slice$