Calculates the maximum by a given selector.

Type signature

(f: (x: number) => number) => ((xs: number[]) => number)

Examples

maximumBy(({ age }) => age)([
  { age: 13 },
  { age: 20 },
  { age: 7 },
  { age: 18 },
]);
// ⇒ { age: 20 }
Try in REPL

Questions

  • How to find a maximum element by a given function?

TypeScript sourceJavaScript source