Function remove

  • Removes the element startIndex, or the elements from startIndex to (but not including) endIndex, from the array.

    Negative indices count backwards from the end of the array. If index is fractional or otherwise invalid, returns a shallow copy of the array.

    Remarks

    This function removes elements by indices. To remove by element value, use reject.

    Example

    import * as A from "flurp/array";

    const removeSecond = A.remove(1);
    removeSecond([10, 20, 30, 40]); // [10, 30, 40]

    const removeLast = A.remove(-1);
    removeLast([10, 20, 30, 40]); // [10, 20, 30]

    const removeSecondAndThird = A.remove(2, 4);
    removeSecondAndThird([10, 20, 30, 40]); // [10, 40]

    Type Parameters

    • T

    Parameters

    • startIndex: number
    • Optional endIndex: number

    Returns ((arr: readonly T[]) => T[])

      • (arr: readonly T[]): T[]
      • Parameters

        • arr: readonly T[]

        Returns T[]