Function removeAtIndex

  • Removes the item at the specified index from the specified items array.

    Type Parameters

    • T

      Type of item in the specified items array.

    Parameters

    • items: T[]

      Array of items containing the item to remove.

    • index: number

      Index of the item to remove.

    Returns T[]

    Copy of array with item at index removed. If the specified items array is empty, returns items.

    RangeError if the specified index is out of bounds.

    const values = [1, 2, 3, 4, 5, 6];

    const updated = removeAtIndex(values, 2);
    // [1, 2, 4, 5, 6]