- 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 - bindKey method
Syntax
_.bindKey(object, key, [partials])
Creates a function that invokes the method at object[key] with partials prepended to the arguments it receives.
Arguments
object (Object) − The object to invoke the method on.
key (string) − The key of the method.
[partials] (...*) − The arguments to be partially applied.
Output
(Function) − Returns the new bound function.
Example
var _ = require('lodash');
var object = {
user: 'Joe',
greet: function(message) {
return this.user + ' : ' + message;
}
};
//Bind this with object provided
updateMessage = _.bindKey(object, 'greet', "Welcome");
var result = updateMessage();
console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
Joe : Welcome
lodash_function.htm
Advertisements