VDL Plugin SDK

drop

Import from @varavel/vdl-plugin-sdk/utils/arrays.

function drop<T>(arr, itemsCount): T[];

Removes a specified number of elements from the beginning of an array and returns the rest.

This function takes an array and a number, and returns a new array with the specified number of elements removed from the start.

Type Parameters

Type ParameterDescription
TThe type of elements in the array.

Parameters

ParameterTypeDescription
arrreadonly T[]The array from which to drop elements.
itemsCountnumberThe number of elements to drop from the beginning of the array.

Returns

T[]

A new array with the specified number of elements removed from the start.

Example

const array = [1, 2, 3, 4, 5];
const result = drop(array, 2);
// result will be [3, 4, 5] since the first two elements are dropped.