Open In App
Related Articles

Lodash _.prototype.reverse() Method

Improve Article
Improve
Save Article
Save
Like Article
Like

Lodash _.prototype.reverse() method of Sequence in lodash is used to mutate the wrapped array. Moreover, it is the wrapper version of the _.reverse method of an array.

Syntax:

_.prototype.reverse();

Parameters:

This method doesn’t accept any parameter.

Return Value:

This method returns the new lodash wrapper instance.

Example 1: In this example, we are getting the reverse of the given array by the use of the lodash _.prototype.reverse() method.

Javascript




// Requiring lodash library
const _ = require('lodash');
 
// Creating an array of integers
let arr = [4, 5, 3];
 
// Calling _.prototype.reverse() method
_(arr).reverse().value();
 
// Displays output
console.log(arr);


Output:

[ 3, 5, 4 ]

Example 2: In this example, we are getting the reverse of the given array by the use of the lodash _.prototype.reverse() method.

Javascript




// Requiring lodash library
const _ = require('lodash');
 
// Creating an array of characters
let arr = ['a', 'b', 'c'];
 
// Calling _.prototype.reverse() method
_(arr).reverse().value();
 
// Displays output
console.log(arr);


Output:

[ 'c', 'b', 'a' ]
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 03 Nov, 2023
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials