Remove
Removes the element at the specified index from the array. This modifies the original array.
Category | Arrays |
Author | Pol Gubau |
Since | 1.0.0 |
Last Updated | 2025-03-15 |
Type | Sync |
Compatibility | Universal |
Example
Input
remove([1, 2, 3], 1)
Output:
[1, 3]
Return
The modified array with the element removed.
Type: array
Props
Name | Type | Default | Required | Description |
---|---|---|---|---|
arr | T[] | null | Yes | The array from which to remove the element. |
index | number | null | Yes | The index of the element to remove. Negative indices count from the end. |
Notes
If the index is out of bounds, the function returns the original array. The array is mutated.
Tags
- array
- remove
- mutation