Register now or log in to join your professional community.
With Commons.Lang you could simply use
ArrayUtils.reverse(int[] array)
Most of the time, it's quicker and more bug-safe to stick with easily available libraries already unit-tested and user-tested when they take care of your problem.
var array_name[4]={5,4,8,6};
array_name.reverse();
var jqArray= ['1', '2', '3'];
var x=jqArray.reverse();
Result=['3','2','1']
var firstArray = [1,2,3];
var result = firstArray.reverse();
result = [3,2,1]
reverse() is a built on function to reverse the order of array.
reverse()
Syntax
arr.reverse()
Parameters : none
Description :
The reverse method transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array.
Examples
var myArray = ['one', 'two', 'three'];
myArray.reverse();
console.log(myArray) // ['three', 'two', 'one']
reverse () Reverse the order of the elements in an array
reverse() function is used to reverse an array data.