https://github.com/xotic750/array-like-slice-x
Cross-browser array-like slicer.
https://github.com/xotic750/array-like-slice-x
array-like browser javascript nodejs slice
Last synced: 11 months ago
JSON representation
Cross-browser array-like slicer.
- Host: GitHub
- URL: https://github.com/xotic750/array-like-slice-x
- Owner: Xotic750
- License: mit
- Created: 2017-09-03T19:00:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T23:29:36.000Z (about 3 years ago)
- Last Synced: 2025-04-30T20:31:55.323Z (11 months ago)
- Topics: array-like, browser, javascript, nodejs, slice
- Language: JavaScript
- Size: 2.58 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## array-like-slice-x
Cross-browser array-like slicer.
### `module.exports(argsObject, [start], [end])` ⇒ Array ⏏
The slice() method returns a shallow copy of a portion of an array into a new
array object selected from begin to end (end not included). The original
array will not be modified.
**Kind**: Exported function
**Returns**: Array - A new array containing the extracted elements.
| Param | Type | Description |
| ---------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| argsObject | Object | The `arguments` to slice. |
| [start] | number | Zero-based index at which to begin extraction. A negative index can be used, indicating an offset from the end of the sequence. slice(-2) extracts the last two elements in the sequence. If begin is undefined, slice begins from index 0. |
| [end] | number | Zero-based index before which to end extraction. Slice extracts up to but not including end. For example, slice([0,1,2,3,4],1,4) extracts the second element through the fourth element (elements indexed 1, 2, and 3). A negative index can be used, indicating an offset from the end of the sequence. slice(2,-1) extracts the third element through the second-to-last element in the sequence. If end is omitted, slice extracts through the end of the sequence (arr.length). If end is greater than the length of the sequence, slice extracts through the end of the sequence (arr.length). |
**Example**
```js
import arrayLikeSlice from 'array-like-slice-x';
const args = (function() {
return arguments;
})('Banana', 'Orange', 'Lemon', 'Apple', 'Mango');
console.log(arrayLikeSlice(args, 1, 3)); // ['Orange','Lemon']
```