VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-reverse-function/

⇱ Lodash _.reverse() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.reverse() Function

Last Updated : 2 Sep, 2024

Lodash _.reverse() is used to reverse the array. This function changes the original array and also returns a new array.

Syntax:

_.reverse( array )

Parameters:

  • This function accepts a single parameter array that holds the array of elements.

Return Value:

  • It returns the reversed array.

Note: Please install lodash module by using npm install lodash before using the below given code.

Example 1: This examples shows that this function effect the original array.

Output:

👁 Image

Example 2: In this example, we will take an array of objects and reverse them.

Output:

👁 Image
Comment