@nevware21/ts-utils
    Preparing search index...

    Function arrUnique

    • Function

      The arrUnique() method returns a new array with duplicate elements removed. Uses strict equality (===) for comparison and maintains insertion order.

      Type Parameters

      • T

        Identifies the base type of array elements

      Parameters

      • theArray: ArrayLike<T>

        The array or array-like object to remove duplicates from

      Returns T[]

      A new array with duplicate values removed, preserving order of first occurrence

      0.14.0

      arrUnique([1, 2, 2, 3, 1, 4]);           // [1, 2, 3, 4]
      arrUnique(["a", "b", "a", "c"]); // ["a", "b", "c"]
      arrUnique([1, "1", 1, "1"]); // [1, "1"]
      arrUnique([]); // []
      arrUnique([1]); // [1]

      // Array-like objects
      arrUnique({ length: 4, 0: 1, 1: 2, 2: 2, 3: 3 }); // [1, 2, 3]