libram
    Preparing search index...

    Function maxBy

    Find the best element of an array, where "best" is defined by some given criteria.

    The array to traverse and find the best element of.

    Either a key on the objects we're looking at that corresponds to numerical values, or a function for mapping these objects to numbers. Essentially, some way of assigning value to the elements of the array.

    Make this true to find the worst element of the array, and false to find the best. Defaults to false.

    Best element by optimizer function

    • Type Parameters

      • T

      Parameters

      • array: T[] | readonly T[]
      • optimizer: (element: T) => number
      • Optionalreverse: boolean

      Returns T

    • Type Parameters

      • S extends string | number | symbol
      • T extends { [x in string | number | symbol]: number }

      Parameters

      • array: T[] | readonly T[]
      • key: S
      • Optionalreverse: boolean

      Returns T