- 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 - rest method
Syntax
_.rest(func, [start=func.length-1])
Creates a function that invokes func with the this binding of the created function and arguments from start and beyond provided as an array.
Arguments
func (Function) − The function to apply a rest parameter to.
[start=func.length-1] (number) − The start position of the rest parameter.
Output
(Function) − Returns the new function.
Example
var _ = require('lodash'); var say = _.rest(function(what, names) { return what + ' ' + _.initial(names).join(', ') + (_.size(names) > 1 ? ' & ' : '') + _.last(names); }); console.log(say('Hello', 'Joe', 'Tom', 'Julie'));
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
Hello Joe, Tom & Julie
lodash_function.htm
Advertisements