- 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 - partial method
Syntax
_.partial(func, [partials])
Creates a function that invokes func with partials prepended to the arguments it receives. This method is like _.bind except it does not alter the this binding.
Arguments
func (Function) − The function to partially apply arguments to.
[partials] (...*) − The arguments to be partially applied.
Output
(Function) − Returns the new partially applied function.
Example
var _ = require('lodash'); var divide = function(a, b) { return b / a}; var divideBy5 = _.partial(divide, 5); var result = divideBy5(10); console.log(result); var divisionOf10 = _.partial(divide, _, 10) result = divisionOf10(5) console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
2 2
lodash_function.htm
Advertisements