Function uniqueItems

  • Returns a new array containing only the unique elements from the input array, preserving their order.

    Returns

    A new array with duplicate elements removed.

    Example

    uniqueItems([1, 2, 2, 3, 1]); // → [1, 2, 3]
    uniqueItems(['a', 'b', 'a']); // → ['a', 'b']

    Remarks

    • Uses a Set internally for efficient duplicate removal.
    • Original array is not modified.

    Type Parameters

    • T

      The type of elements in the array.

    Parameters

    • items: T[]

      The array from which to remove duplicates.

    Returns T[]

Generated using TypeDoc