Lodash - flip method
Syntax
_.flip(func)
Creates a function that invokes func with arguments reversed.
Arguments
func (Function) − The function to flip arguments for.
Output
(Function) − Returns the new flipped function.
Example
var _ = require('lodash');
var flipped = _.flip(function() {
return _.toArray(arguments);
});
console.log(flipped(1, 2, 3, 4));
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 4, 3, 2, 1 ]
lodash_function.htm
Advertisements