Array.prototype.reversebeginnerconst arr = [1, 2, 3, 4, 5]
arr.reverse() // β [5, 4, 3, 2, 1]Use reverse() to invert the order of elements in an array in place.
reverse() mutates the original array in place. To avoid mutation, copy the array first with slice() or the spread operator.
const reversed = arr.slice().reverse() // original unchanged