[1, 55, 77, 88] // ...would return [55, 77, 88]
adding additional examples:
[1, 55, 77, 88, 99, 22, 33, 44] // ...would return [88, 99, 22, 33, 44] [1] // ...would return []
You can call:
arr.slice(Math.max(arr.length - 5, 1))
If you don't want to exclude the first element, use
arr.slice(Math.max(arr.length - 5, 0))
1.4m articles
1.4m replys
5 comments
57.0k users