Last Updated : 03 Nov, 2023
Lodash _.methodOf() method creates a function that invokes the method at a given path of the object. Any additional arguments are provided to the invoked method.
Syntax:_.methodOf(object, args);Parameters:
This method returns the new invoker function.
Example 1: In this example, we are using the lodash _.methodOf() method.
JavaScript
// Requiring the lodash library
const _ = require("lodash");
// Use of _.methodOf() method
let array = _.times(4, _.constant);
let object =
{
'www': array,
'geeks': array,
'for': array,
'geek': array
};
let gfg = _.map(['geeks[1]',
'geek[2]'], _.methodOf(object));
// Printing the output
console.log(gfg);
Output:
[1, 2]
Example 2: In this example, we are using the lodash _.methodOf() method.
JavaScript
// Requiring the lodash library
const _ = require("lodash");
// Use of _.methodOf() method
let array = _.times(4, _.constant);
let object =
{
'www': array,
'geeks': array,
'for': array,
'geek': array
};
let gfg = _.map([['www', '1'], ['for',
'0']], _.methodOf(object));
// Printing the output
console.log(gfg);
Output :
[1, 0]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4