Skip to content

max

基础用法

给定一个项目数组和一个用于获取每个项目值的函数,返回具有最大值的项目。在内部使用_.boil(注意:这里可能是个虚构的函数名,因为Lodash库中并没有直接名为_.boil的函数,可能是指某种内部处理或自定义函数)。

import { max } from 'radash'
const fish = [
{
name: 'Marlin',
weight: 105,
source: 'ocean'
},
{
name: 'Bass',
weight: 8,
source: 'lake'
},
{
name: 'Trout',
weight: 13,
source: 'lake'
}
]
max(fish, f => f.weight) // => {name: "Marlin", weight: 105, source: "ocean"}