ArrayUnion()
Summary
Returns a new array containing all unique elements from arrays a and b.
Changes
Added to Version 2026.
arr = ArrayUnion(array a, array b)
| Argument | Contents |
|---|---|
| a | An array |
| b | An array |
Returns
An array with the elements in a that were found in b.
Notes
-
Returns a new array containing all unique elements from arrays
aandb. -
Elements from a appear first, followed by elements from b that do not already exist in a.
Example
// A simple example with numeric and null values
a = {9,2,1,6,2,5,3}
b = {6,7,2,3,6,1, null}
c = ArrayUnion(a, b) // c = { 9, 2, 1, 6, 5, 3, 7, null }
// Subarrays are compared and matched, if dups exist they are removed
a= {{9,2,1},6,{2,5,3}}
b = {{6,7,2}, {3,6,1}, {2,5,3}}
c = ArrayUnion(a, b) // c = { { 9, 2, 1 }, 6, { 2, 5, 3 }, { 6, 7, 2 }, { 3, 6, 1 } }
// string comparison is case-sensitive
a = {1, "A", "B", "bc", "BC"}
b = {2, "a", "b", "Bc", "BC"}
c = ArrayUnion(a, b) // c = { 1, "A", "B", "bc", "BC", 2, "a", "b", "Bc" }
See Also
| Function | Summary |
|---|---|
| ArrayExclude() | Excludes elements from an array |
| ArrayIntersect() |
Returns a new array containing all unique elements from arrays |
| ExcludeArrayElements() | Removes elements from an array |
| InsertArrayElements() | Inserts elements into an array |