服务器

Array

Collection

Date

Function

Lang

Math

Number

Object

Seq

String

Util

Properties

Methods

_.maxBy(array, iteratee=_.identity)

此方法与_.max类似,不同之处在于它接受针对数组中每个元素调用的iteratee,以生成排序值的标准。 迭代器被调用一个参数:(value)。

初始

4.0.0

参数
  1. array (Array):迭代的数组。
  2. [iteratee=_.identity] (Function):每个元素调用的迭代器。
返回

(*):返回最大值。

var objects = [{ 'n': 1 }, { 'n': 2 }];
 
_.maxBy(objects, function(o) { return o.n; });
// => { 'n': 2 }
 
// The `_.property` iteratee shorthand.
_.maxBy(objects, 'n');
// => { 'n': 2 }