javascript 5 element of a list code example Example: return last two values of array in javascript arr.slice(Math.max(arr.length - 5, 1))