Version: v0.7.0 - Beta.  We welcome contributors & feedback.


remove($index, $numItems = 1) -> any


Remove an item starting at $index and return its value.

If $index is negative, it counts from the end of the list (the last item is at -1).

If an item does not exist at that index, it returns the default value of the list (e.g. an empty string). If $numItems is greater than one, it returns an empty list.

This function is the opposite of $insert.

$items = ['a', 'b', 'c', 'd', 'e']

//= 'a'

//= ['b', 'c', 'd', 'e']

//= 'd'

//= ['b', 'c', 'e']

//= ''

Multiple Items 

If numItems is more than 1, the values will be returned as a List.

If items do not exist at the index, an empty list will be returned.

$items = ['a', 'b', 'c', 'd', 'e']

// Remove the first 2 items
$items.remove(1, 2)
//= ['a', 'b']

//= ['c', 'd', 'e']

$items.remove(99, 2)
//= []

See Also