Lodash _.flowRight() 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 _.flowRight() method is used to create a new composite function that invokes the provided functions from right to left, where each of the successive invocations is provided the return value of the previous. It is almost the same as _.flow() method.
Syntax:
_.flowRight( funcs )
Parameters: This method accepts a single parameter as mentioned above and described below:
- funcs: This parameter holds the functions to invoke. It is an optional parameter.
Return Value: This method returns the new composite function.
Example 1:
Javascript
| // Requiring the lodash library  const _ = require("lodash");  // Function to calculate the// Cube of a numberfunctioncube(number) {  returnnumber * number * number;}// Using the _.flowRight() method  varmultiplycube = _.flowRight([cube, _.multiply]);// Printing the outputconsole.log(multiplycube(2, 3)); | 
Output:
216
Example 2:
Javascript
| // Requiring the lodash library  const _ = require("lodash");  // Function to calculate the// double value of a numberfunctiondoubled(number) {  returnnumber * 2;}// Using the _.flowRight() method  varadddoubled =  _.flowRight([doubled, _.add]);// Printing the outputconsole.log(adddoubled(6, 8)); | 
Output:
28
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek 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!
 
				 
					

