ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## minBy + [link](./minBy "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L14018 "View in source.") + [npm](https://www.npmjs.com/package/lodash.minby "See the npm package.") ``` _.minBy(array, [iteratee=_.identity]) ``` 这个方法类似 `_.min`。 除了它接受 iteratee 调用每一个元素,根据返回的 value 决定排序准则。 iteratee 会传入1个参数:(value)。 ### 参数 1. array (Array) 要遍历的数组 2. [iteratee=_.identity] (Function|Object|string) 这个函数会处理每一个元素 ### 返回值 (\*) 返回最小值 ### 示例 ``` var objects = [{ 'n': 1 }, { 'n': 2 }]; _.minBy(objects, function(o) { return o.n; }); // => { 'n': 1 } // 使用了 `_.property` iteratee 的回调结果 _.minBy(objects, 'n'); // => { 'n': 1 } ```