|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
759 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Removes elements from an array at specified indices and returns the removed elements.
|
|---|
| 3 | *
|
|---|
| 4 | * This function supports negative indices, which count from the end of the array.
|
|---|
| 5 | *
|
|---|
| 6 | * @template T
|
|---|
| 7 | * @param {T[]} arr - The array from which elements will be removed.
|
|---|
| 8 | * @param {number[]} indicesToRemove - An array of indices specifying the positions of elements to remove.
|
|---|
| 9 | * @returns {Array<T | undefined>} An array containing the elements that were removed from the original array.
|
|---|
| 10 | *
|
|---|
| 11 | * @example
|
|---|
| 12 | * const numbers = [10, 20, 30, 40, 50];
|
|---|
| 13 | * const removed = pullAt(numbers, [1, 3, 4]);
|
|---|
| 14 | * console.log(removed); // [20, 40, 50]
|
|---|
| 15 | * console.log(numbers); // [10, 30]
|
|---|
| 16 | */
|
|---|
| 17 | declare function pullAt<T>(arr: T[], indicesToRemove: number[]): T[];
|
|---|
| 18 |
|
|---|
| 19 | export { pullAt };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.