function union
union<T>(...arrays: Iterable<T>[]): T[]Returns all distinct elements that appear in any of the given arrays.
Examples
Example 1
Example 1
import { union } from "@std/collections/union"; import { assertEquals } from "@std/assert/assert_equals"; const soupIngredients = ["Pepper", "Carrots", "Leek"]; const saladIngredients = ["Carrots", "Radicchio", "Pepper"]; const shoppingList = union(soupIngredients, saladIngredients); assertEquals(shoppingList, ["Pepper", "Carrots", "Leek", "Radicchio"]);
Type Parameters
TParameters
...arrays: Iterable<T>[]Return Type
T[]