Remove

Removes the element at the specified index from the array. This modifies the original array.

CategoryArrays
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeSync
CompatibilityUniversal

Example

  • Input

    remove([1, 2, 3], 1)

    Output:

    [1, 3]

Return

The modified array with the element removed.

Type: array

Props

NameTypeDefaultRequiredDescription
arrT[]nullYesThe array from which to remove the element.
indexnumbernullYesThe 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

Related