slice()

Slice does not modify the original array, but instead returns a shallow copy of elements from the original array.

This function is valid in v2.0.0 to v2.14.0. This function has been downloaded 49 times.

Parameters

{Array|Arguments|Object} array
Array or array-like object to shallow copy.
{number=} begin Optional
Zero-based index at which to begin extraction. A negative index can be used, indicating an offset from the end of the sequence. slice(array,-2) extracts the last two elements in the sequence. If begin is undefined, slice begins from index 0.
{number=} end Optional, Default:array.length
Zero-based index before which to end extraction. slice extracts up to but not including end. For example, slice(array,1,4) extracts the second element through the fourth element (elements indexed 1, 2, and 3). A negative index can be used, indicating an offset from the end of the sequence. slice(array,2,-1) extracts the third element through the second-to-last element in the sequence. If end is omitted, slice extracts through the end of the sequence (array.length). If end is greater than the length of the sequence, slice extracts through the end of the sequence (array.length).

Returns

{Array}
A new array containing the extracted elements.

Required Function

This function requires the following function which is included automatically:

  • alias()
    Binds a context to a given function within that context.