I am saving some data in order using arrays, and I want to add a function that the user can reverse the list. I can\'t think of any possible method, so if anybo
array
Here is a version which does not require temp array.
function inplaceReverse(arr) { var i = 0; while (i < arr.length - 1) { arr.splice(i, 0, arr.pop()); i++; } return arr; } // Useage: var arr = [1, 2, 3]; console.log(inplaceReverse(arr)); // [3, 2, 1]