JS: Array.prototype.toReversed

By Xah Lee. Date: .

(new in JS: ECMAScript 2023)

same as JS: Array.prototype.reverse but return a copy.

const xx = [3, 4, 5];
const yy = xx.toReversed();

console.log(xx);
// [ 3, 4, 5 ]

console.log(yy);
// [ 5, 4, 3 ]

JavaScript. Sort, Reverse