1var arr = [34, 234, 567, 4];
2print(arr);
3var new_arr = arr.reverse();
4print(new_arr);
5
1const array1 = [1,2,3,4];
2console.log('array1:', array1);
3//"array1:" Array [1, 2, 3, 4]
4
5const reversed = array1.reverse();
6console.log('reversed:', reversed);
7//"reversed:" Array [4, 3, 2, 1]
8
9// Careful: reverse is destructive -- it changes the original array.
10console.log('array1:', array1);
11//"array1:" Array [4, 3, 2, 1]
1var arr = [1, 2, 3, 4, 5, 6, 7];
2console.log (arr.reverse ());
3
4for (i = 0; i < arr.length / 2; i++) {
5 var temp = arr[i];
6 temp =arr[arr.length - 1 - i];
7 temp = temp;
8}
9console.log (arr);
1const array1 = ['one', 'two', 'three'];
2console.log('array1:', array1);
3//["one", "two", "three"]
4
5const reversed = array1.reverse();
6console.log('reversed:', reversed);
7//["three", "two", "one"]
8
9// Careful: reverse is destructive -- it changes the original array.
10console.log('array1:', array1);
11//["three", "two", "one"]