- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - flow method
Syntax
_.flow([funcs])
Creates a function that returns the result of invoking the given functions with the this binding of the created function, where each successive invocation is supplied the return value of the previous.
Arguments
[funcs] (...(Function|Function[])) − The functions to invoke.
Output
(Function) − Returns the new composite function.
Example
var _ = require('lodash'); function square(n) { return n * n; } var addAndSquare = _.flow([_.add, square]); var result = addAndSquare(3, 2); console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
25
lodash_util.htm
Advertisements