Wednesday, September 25, 2024
Google search engine
HomeLanguagesJavascriptLodash _.flowRight() Method

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 number
function cube(number) {
  return number * number * number;
}
 
// Using the _.flowRight() method 
var multiplycube =
 _.flowRight([cube, _.multiply]);
 
// Printing the output
console.log(multiplycube(2, 3));


Output: 

216

Example 2:   

Javascript




// Requiring the lodash library 
const _ = require("lodash"); 
 
// Function to calculate the
// double value of a number
function doubled(number) {
  return number * 2;
}
 
// Using the _.flowRight() method 
var adddoubled =
  _.flowRight([doubled, _.add]);
 
// Printing the output
console.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, 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

Most Popular

Recent Comments