HomeLanguagesJavascriptLodash _.prototype.reverse() Method

Lodash _.prototype.reverse() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.prototype.reverse() method of Sequence in lodash is used to mutate the wrapped array. Moreover, it is the wrapper version of _.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:

Javascript




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


Output:

[ 3, 5, 4 ]

Example 2:

Javascript




// Requiring lodash library
const _ = require('lodash');
  
// Creating an array of characters
var 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, neveropen 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!
RELATED ARTICLES

4 COMMENTS

Most Popular

Dominic
32712 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7085 POSTS0 COMMENTS
Nicole Veronica
12225 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12308 POSTS0 COMMENTS
Shaida Kate Naidoo
7202 POSTS0 COMMENTS
Ted Musemwa
7467 POSTS0 COMMENTS
Thapelo Manthata
7187 POSTS0 COMMENTS
Umr Jansen
7171 POSTS0 COMMENTS