Lodash _.prototype.reverse() Method
Last Updated :
03 Nov, 2023
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
const _ = require( 'lodash' );
let arr = [4, 5, 3];
_(arr).reverse().value();
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
const _ = require( 'lodash' );
let arr = [ 'a' , 'b' , 'c' ];
_(arr).reverse().value();
console.log(arr);
|
Output:
[ 'c', 'b', 'a' ]
Share your thoughts in the comments
Please Login to comment...