Array.slice

Array.slice

Array.slice

Function

Copy the array fragment according to the starting and ending indexes.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
startIntNo0Starting subscript; a negative number means counting backwards from the tail.
endIntNoArray lengthEnd subscript, excluding this position; a negative number means backward calculation from the tail.

Return value

TypeDescription
ArrayReturns a new array.

Example

Notes

  • The original array will not be modified.