The arrDrop() method returns a new array with the first n elements removed from the source array. If n is greater than the array length, returns empty array. If n is negative or 0, returns all elements.
Identifies the base type of array elements
The array or array-like object to drop from
The number of elements to drop from the beginning
A new array with the first n elements removed
0.14.0
arrDrop([1, 2, 3, 4, 5], 2); // [3, 4, 5]arrDrop(["a", "b", "c"], 1); // ["b", "c"]arrDrop([1, 2], 5); // []arrDrop([1, 2, 3], 0); // [1, 2, 3]arrDrop([1, 2, 3], -1); // [1, 2, 3]// Array-like objectsarrDrop({ length: 4, 0: 1, 1: 2, 2: 3, 3: 4 }, 2); // [3, 4] Copy
arrDrop([1, 2, 3, 4, 5], 2); // [3, 4, 5]arrDrop(["a", "b", "c"], 1); // ["b", "c"]arrDrop([1, 2], 5); // []arrDrop([1, 2, 3], 0); // [1, 2, 3]arrDrop([1, 2, 3], -1); // [1, 2, 3]// Array-like objectsarrDrop({ length: 4, 0: 1, 1: 2, 2: 3, 3: 4 }, 2); // [3, 4]
The arrDrop() method returns a new array with the first n elements removed from the source array. If n is greater than the array length, returns empty array. If n is negative or 0, returns all elements.