Array.prototype.toReversedbeginnerconst arr = [1, 2, 3]
arr.toReversed() // β [3, 2, 1]
arr // β [1, 2, 3] (unchanged)Use toReversed() to get a reversed copy of an array without mutating the original.
Array.prototype.toReversed() returns a new array with the elements in reversed order. Unlike reverse(), it does not mutate the original array.
Challenge: Implement reverseImmutable(arr) that returns arr.toReversed().
reverseImmutable([1, 2, 3]) // β [3, 2, 1]
reverseImmutable([10, 20]) // β [20, 10]