VDL Plugin SDK

xor

Import from @varavel/vdl-plugin-sdk/utils/arrays.

function xor<T>(arr1, arr2): T[];

Computes the symmetric difference between two arrays. The symmetric difference is the set of elements which are in either of the arrays, but not in their intersection.

Type Parameters

Type ParameterDescription
TThe type of elements in the array.

Parameters

ParameterTypeDescription
arr1readonly T[]The first array.
arr2readonly T[]The second array.

Returns

T[]

An array containing the elements that are present in either arr1 or arr2 but not in both.

Examples

// Returns [1, 2, 5, 6]
xor([1, 2, 3, 4], [3, 4, 5, 6]);
// Returns ['a', 'c']
xor(['a', 'b'], ['b', 'c']);