Javascript reverse


JS Array.reverse() method reverses the order of the array elements, and returns the new array.

var arr = new Array(1,2,3,4,5);
var ret = arr.reverse();
alert(ret); //5,4,3,2,1

reverse() can be used together with other methods.

var arr = new Array(1,2,3,4,5);
var ret = arr.reverse().join(":");
alert(ret); //5:4:3:2:1