javascript reverse array order code example
Example 1: javascript reverse array
var arr = [34, 234, 567, 4];
print(arr);
var new_arr = arr.reverse();
print(new_arr);
Example 2: js reverse nested array
var reversed = array.map(function reverse(item) {
return Array.isArray(item) && Array.isArray(item[0])
? item.map(reverse)
: item.reverse();
});
Example 3: reverse array javascript
var rev = arr.reverse();
Example 4: reverse array in javascript
const reverseArray = arr => arr.reduce((acc, val) => [val, ...acc], [])