+ 3
Reverse in javascript
explain reverse method in javascript, ?
10 Answers
+ 5
Reverse method is used to reverse an array.
const a = [1,2,3].reverse();
console.log(a);
+ 4
Consider this :
const array = [1,2,3,4,5];
console.log(array.reverse()); // 5,4,3,2,1
reverse() method is used to reverse an array in javascript :))
+ 3
thanks for the answer âș
+ 3
Bear in mind, reverse method mutates the input array.
If you want unmutable input, try
const reversed = [...arr].reverse();
+ 3
Actually, I was a bit wrong :))
const a = [1,2,3,4,5];
const b = a.reverse();
console.log(b); // 5,4,3,2,1
console.log(a); // 5,4,3,2,1
Both of the array will give the reversed array. Although a was supposed to be the same.
0
ok
0
why? errroooor
0
oh đ
well
0
welllll