Lodash - max 方法

语法

_.max(array)

计算数组的最大值。如果数组为空或为 false,则返回 undefined。

参数

  • array (Array) − 要迭代的数组。

输出

  • (*) − 返回最大值。

示例

var _ = require('lodash');
 
console.log(_.max([ 4, 6, 1, 5]));

将上述程序保存在tester.js中。运行以下命令执行该程序。

命令

\>node tester.js

输出

6

lodash_math.html