Tweakr
    Preparing search index...

    Function uniqBy

    • Creates a new array with unique elements determined by the result of an iteratee function.

      The iteratee is invoked for each element to generate a key by which uniqueness is computed. Elements that produce the same key are treated as duplicates and only the first occurrence is kept.

      Type Parameters

      • T

      Parameters

      • array: T[]

        The array to process.

      • iteratee: (item: T) => any

        The function invoked per element to generate the key for comparison.

      Returns T[]

      A new array containing unique elements based on the computed key.

      uniqBy([1.2, 2.3, 2.4, 3.1], Math.floor);
      // → [1.2, 2.3, 3.1]

      uniqBy([{ id: 1 }, { id: 2 }, { id: 1 }], x => x.id);
      // → [{ id: 1 }, { id: 2 }]

      1.0.0