- 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 - reArg method
Syntax
_.rearg(func, indexes)
Creates a function that invokes func with arguments arranged according to the specified indexes where the argument value at the first index is provided as the first argument, the argument value at the second index is provided as the second argument, and so on.
Arguments
func (Function) − The function to rearrange arguments for.
indexes (...(number|number[])) − The arranged argument indexes.
Output
(Function) − Returns the new function.
Example
var _ = require('lodash'); var rearged = _.rearg(function(a, b, c) { return [a, b, c]; }, [2, 0, 1]); console.log(rearged('b', 'c', 'a'));
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 'a', 'b', 'c' ]
lodash_function.htm
Advertisements
To Continue Learning Please Login
Login with Google