💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## invokeMap + [link](./invokeMap "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L7818 "View in source.") + [npm](https://www.npmjs.com/package/lodash.invokemap "See the npm package.") ``` _.invokeMap(collection, path, [args]) ``` 调用 `path` 的方法处理集合中的每一个元素,返回处理的数组。 如何附加的参数会传入到调用方法中。如果方法名是个函数,集合中的每个元素都会被调用到。 ### 参数 1. collection (Array|Object) 需要遍历的集合 2. path (Array|Function|string) 要调用的方法名 或者 这个函数会处理每一个元素 3. [args] (...*) The arguments to invoke each method with. ### 返回值 (Array) 返回数组结果 ### 示例 ``` _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); // => [[1, 5, 7], [1, 2, 3]] _.invokeMap([123, 456], String.prototype.split, ''); // => [['1', '2', '3'], ['4', '5', '6']] ```