Open In App

JavaScript Array toReversed() Method

Last Updated : 15 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The toReversed() method in Javascript arrays returns a new array with the elements in reversed order and the original array remains unaffected. The toReversed() method, introduced in ECMAScript 2023, offers a way to reverse the order of elements in an array.

Unlike the sort() method, it creates a new array with the elements arranged in reverse order. This method preserves the original array, ensuring it remains unmodified.

Syntax:

It will not take any parameter and return the array with elements in reverse order.

let result_array = actual_array.toReversed()

Example: JavaScript program to reverse the elements in an array

JavaScript
let actual_array = [60, 78, 90, 34, 67];
console.log("Existing Array: ", actual_array);

let result_array = actual_array
    .toReversed();
console.log("Final Array: ", result_array);

Output:

Existing Array: [60, 78, 90, 34, 67]
Final Array:  [67, 34, 90, 78, 60]

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads