Skip to content

drop

Summary

Returns a new list without the first n elements of the original list.

Tip

This function is curried.

Tip

Act as a transducer when composed with take, filter or map.

Description

Drops the first n items from xs and returns the rest in a new list of the same type.

When n is 0 or negative drop does nothing. When n is larger than the number of items drop returns an empty list of the same type.

Examples

Works with arrays and objects

1
2
3
4
5
6
7
const drop2 = drop(2);

drop2([1, 2, 3]);
//=> [3]

drop2({a: 1, b: 2, c: 3});
//=> {c: 3}

Parameters

Name Type Description
n number Number of items to drop.
xs Array or Object List to drop from.

Return

Array or Object