javascript array slice with limit and off 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))