Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Lodash _.prototype.reverse() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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' ]
My Personal Notes arrow_drop_up
Last Updated : 18 Sep, 2020
Like Article
Save Article
Similar Reads
Related Tutorials