Array
symDiff

Returns a new array containing elements which are in either this or other, but not in both.

It uses isEql for deep comparison of values.

Venn Diagram

Related

Syntax

import { symDiff } from '@opentf/std';
 
symDiff(
  collections: unknown[][] = [],
  by?: (val: unknown) => unknown
)

Examples

const evens = [2, 4, 6, 8];
const squares = [1, 4, 9];
symDiff([evens, squares]) //=> [2, 6, 8, 1, 9]);
 
const bucket1 = ['Fruits', 'Vegs', 'Eggs', 'Cookies', 'Nuts'];
const bucket2 = ['fruits', 'Snacks', 'cookies'];
symDiff([bucket1, bucket2], (v) => v.toLowerCase()) 
//=> [
//  'Vegs',
//  'Eggs',
//  'Nuts',
//  'Snacks',
// ]

Try