array slice last n elements code example
Example 1: javascript delete second last element of array
arr.splice(arr.length - 2, 1);
Example 2: array cut only last 5 element
arr.slice(Math.max(arr.length - 5, 0))
arr.splice(arr.length - 2, 1);
arr.slice(Math.max(arr.length - 5, 0))