@writetome51/array-get-and-remove-by-index
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

getAndRemoveByIndex<T>(
      index: number,
      array: T[]
): T

Removes and returns 1 item (accessed by index) from array.
The index can be negative or positive.

Examples

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

import {getAndRemoveByIndex} from '@writetome51/array-get-and-remove-by-index';

Package Sidebar

Install

npm i @writetome51/array-get-and-remove-by-index

Weekly Downloads

1

Version

3.0.0

License

MIT

Unpacked Size

2.85 kB

Total Files

5

Last publish

Collaborators

  • writetome51