cut array js code example
Example 1: javascript copy array
var oldColors=["red","green","blue"];
var newColors = oldColors.slice(); //make a clone/copy of oldColors
Example 2: array cut only last 5 element
arr.slice(Math.max(arr.length - 5, 0))
Example 3: js slice
const arr=[1,2,3,4,5];
const slicedArr = arr.slice(1,4); // slicedArr = [2,3,4]