js array return first 5 items code example
Example 1: return last two values of array in javascript
arr.slice(Math.max(arr.length - 5, 1))
Example 2: array index javascript show only first 2 elements
array.slice(0, n);
arr.slice(Math.max(arr.length - 5, 1))
array.slice(0, n);