Module

std/collections/union.ts>union

Deno standard library
Go to Latest
function union
import { union } from "https://dotland.deno.dev/std@0.130.0/collections/union.ts";

Returns all distinct elements that appear in any of the given arrays

Example:

import { union } from "https://deno.land/std@0.130.0/collections/mod.ts";
import { assertEquals } from "https://deno.land/std@0.130.0/testing/asserts.ts";

const soupIngredients = [ 'Pepper', 'Carrots', 'Leek' ]
const saladIngredients = [ 'Carrots', 'Radicchio', 'Pepper' ]
const shoppingList = union(soupIngredients, saladIngredients)

assertEquals(shoppingList, [ 'Pepper', 'Carrots', 'Leek', 'Radicchio' ])

Parameters

...arrays: (readonly T[])[]