https://github.com/writetome51/array-get-and-remove-by-index
Removes and returns item from array, accessed by its index
https://github.com/writetome51/array-get-and-remove-by-index
array-manipulations get-item
Last synced: 6 days ago
JSON representation
Removes and returns item from array, accessed by its index
- Host: GitHub
- URL: https://github.com/writetome51/array-get-and-remove-by-index
- Owner: writetome51
- License: mit
- Created: 2018-11-01T05:30:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-02T15:34:38.000Z (about 5 years ago)
- Last Synced: 2025-10-23T16:24:55.760Z (8 months ago)
- Topics: array-manipulations, get-item
- Language: JavaScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# getAndRemoveByIndex\(
index: number,
array: T[]
): T
Removes and returns 1 item (accessed by `index`) from `array`.
The `index` can be negative or positive.
## Examples
```js
let arr = [10,20,30,40,50];
getAndRemoveByIndex(2, arr);
// --> 30
// arr is now [10,20,40,50]
arr = [10,20,30,40,50];
getAndRemoveByIndex(-2, arr);
// --> 40
// arr is now [10,20,30,50]
```
## Installation
`npm i @writetome51/array-get-and-remove-by-index`
## Loading
```js
import {getAndRemoveByIndex} from '@writetome51/array-get-and-remove-by-index';
```