企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## method + [link](./method "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L13397 "View in source.") + [npm](https://www.npmjs.com/package/lodash.method "See the npm package.") ``` _.method(path, [args]) ``` 创建一个调用给定对象 `path` 上的函数。 任何附加的参数都会传入这个调用函数中。 ### 参数 1. path (Array|string) 调用函数所在对象的路径 2. [args] (...*) 传递给调用函数的参数 ### 返回值 (Function) 返回新的函数 ### 示例 ``` var objects = [ { 'a': { 'b': { 'c': _.constant(2) } } }, { 'a': { 'b': { 'c': _.constant(1) } } } ]; _.map(objects, _.method('a.b.c')); // => [2, 1] _.invokeMap(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c'); // => [1, 2] ```