Skip to content

dropLast

ts
function Array.dropLast<T>(
    target: readonly T[],
    amount: number,
): readonly T[]

Removes amount of elements from the end of the target array.

Example

ts
import { Array } from "@monstermann/array";

Array.dropLast([1, 2, 3, 4, 5], 2); // [1, 2, 3]
ts
import { Array } from "@monstermann/array";

pipe([1, 2, 3, 4, 5], Array.dropLast(2)); // [1, 2, 3]