For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/fp/xor.md.

xor (Functional Programming) es-toolkit

Creates a function that returns values that appear in exactly one of two arrays. Use it with pipe.

const result = pipe(array, xor(secondArray));
Info

Prefer the original es-toolkit xor in ordinary code. Use this fp variant when composing transformations with pipe.

Usage

xor returns the symmetric difference of the piped array and secondArray, without duplicate values.

import { pipe, xor } from 'es-toolkit/fp';

pipe([1, 2, 3], xor([2, 3, 4])); // => [1, 4]

Parameters

secondArrayreadonly T[]required

The array to compare with the piped array.

Returns

A function that maps a readonly T[] to the symmetric difference.

(array: readonly T[]) => T[]
Source: es-toolkit

Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.