This is the example of the array
arr = [1,2,3,4,5];
I expect to have this kind of result
arr = [5];
This is the example of the array
arr = [1,2,3,4,5];
I expect to have this kind of result
arr = [5];
Use Splice/Slice function as below:
var arr = [1, 2, 3, 4, 5];
arr = arr.slice(-1);
console.log(arr);
OR
var arr = [1, 2, 3, 4, 5];
arr = arr.splice(arr.length - 1,1);
console.log(arr);