Creates a shallow copy of a portion of an array from start up to, but not including, end.
start
end
The array to slice.
The index to start extraction. Defaults to 0.
0
Optional
The index before which to end extraction. If omitted, extracts through the end of the array.
A new array containing the extracted elements.
slice([1, 2, 3, 4], 1, 3);// → [2, 3]slice(["a", "b", "c"]);// → ["a", "b", "c"] Copy
slice([1, 2, 3, 4], 1, 3);// → [2, 3]slice(["a", "b", "c"]);// → ["a", "b", "c"]
1.0.0
Creates a shallow copy of a portion of an array from
start
up to, but not including,end
.