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

    Function arrUnion

    • The arrUnion() method returns a new array containing all unique elements from all provided arrays. Uses the SameValueZero comparison (like strict equality ===, except that NaN is equal to NaN) and maintains insertion order.

      Like the other array helpers (eg. arrForEach) a string (or String object) is read by index, so it is split into its UTF-16 code units (a surrogate pair, eg. an emoji, is two values), unlike arrFrom, which splits it into its code points (as do the iterator helpers, eg. iterUnion, on a runtime with Symbol.iterator).

      Type Parameters

      • T

        Identifies the base type of array elements

      Parameters

      • ...arrays: ArrayLike<T>[]

        One or more arrays to combine

      Returns T[]

      A new array containing all unique elements from all arrays

      0.14.0

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

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