The code to reverse an array in-place iteratively is a matter of swapping elements from one end to the other. The algorithm iterates from one end of the array to the middle of the array, swapping characters and for a zero indexed array. This algorithm has time complexity and space complexity .
a.reverse() returns a new array and does not perform an in-place reverse.
The recursive version of this algorithm is a useful study of recursion, but would not be used due to its worse performance. This algorithm has time complexity and space complexity .