- 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 - methodOf method
Syntax
_.methodOf(object, [args])
The opposite of _.method; this method creates a function that invokes the method at a given path of object. Any additional arguments are provided to the invoked method.
Arguments
object (Object) − The object to query.
[args] (...*) − The arguments to invoke the method with.
Output
(Function) − Returns the new invoker function.
Example
var _ = require('lodash'); var array = _.times(3, _.constant); var object = { 'a': array, 'b': array, 'c': array }; console.log(_.map(['a[2]', 'c[0]'], _.methodOf(object))); console.log(_.map([['a', '2'], ['c', '0']], _.methodOf(object)));
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 2, 0 ] [ 2, 0 ]
lodash_util.htm
Advertisements