To move item in array to last position with JavaScript, we use the splice method.
For instance, we write
const a = [1, 2, 5, 4, 3];
a.splice(4, 0, a.splice(2, 1)[0]);
console.log(a);
to remove the 3rd element from the array and return it in an array with a.splice(2, 1).
We get the removed item with index 0.
And then we put it after index 4 by calling splice again with 4, 0, and a.splice(2, 1)[0].