- 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 - overArgs method
Syntax
_.overArgs(func, [transforms=[_.identity]])
Creates a function that invokes func with its arguments transformed.
Arguments
func (Function) − The function to wrap.
[transforms=[_.identity]] (...(Function|Function[])) − The argument transforms.
Output
(Function) − Returns the new function.
Example
var _ = require('lodash'); function doubled(n) { return n * 2; } function square(n) { return n * n; } var func = _.overArgs(function(x, y) { return [x, y]; }, [square, doubled]); console.log(func(9, 3)); console.log(func(10, 5));
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 81, 6 ] [ 100, 10 ]
lodash_function.htm
Advertisements