arr.slice()
Let str = "test";
let arr = ["t", "e", "s", "t"];
alert( str.slice(1, 3) ); // es
alert( arr.slice(1, 3) ); // e,s
alert( str.slice(-2) ); // st
alert( arr.slice(-2) ); // s,t It returns a new array where it copies all items start index "start" to "end" (not including "end").
Both start and end can be negative, in that case position from array end is assumed.
Syntax
Arr.slice(start, end)
Semantic portal