matician - v2.0.0
    Preparing search index...

    Function minBy

    • Finds the minimum numeric value of a specified property in an array of objects.

      Type Parameters

      • T extends Record<string, any>

        The type of objects in the array.

      Parameters

      • items: T[]

        The array of objects.

      • key: keyof T

        The key whose numeric values will be compared.

      Returns number

      The minimum value, or Infinity if no valid number is found.

      const data = [{ a: 5 }, { a: 2 }, { a: 9 }];
      minBy(data, 'a'); // Returns 2