Function deleteAt

Returns a new array with the element at the specified position removed.

  • If the position is negative, the element will be removed from the end of the array.
  • If the position is out of bounds, a new array with the same elements will be returned.
const a = [1, 2, 3, 4, 5];
const b = deleteAt(2)(a); // [1, 2, 4, 5]
const c = deleteAt(-2)(a); // [1, 2, 3, 5]
const d = deleteAt(10)(a); // [1, 2, 3, 4, 5]
  • Type Parameters

    • P extends number

    Parameters

    • position: P

    Returns <S extends readonly unknown[]>(source: S) => DeleteAt<P, S>