equalsUnordered
Order-independent (set-style) array equality.
Two arrays are considered equal when they have the same length and every
element of arr1 has at least one structural match in arr2 (and vice
versa via the length check). Nested arrays are compared recursively with
the same order-independent semantics. Nested plain objects are compared
with equalsShallow from object/. All other values use strict
equality (===).
Use this when the inputs represent unordered collections (sets, tags…). For positional equality use equalsShallow or equalsDeep from this category.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
arr1 | readonly T[] | First array |
arr2 | readonly T[] | Second array |
Returns
Section titled “Returns”boolean — true if both arrays contain the same items regardless of order, false otherwise.
Examples
Section titled “Examples”Compare identical arrays regardless of order
Section titled “Compare identical arrays regardless of order”Returns true when both arrays contain the same elements, in any order.
Detect different arrays
Section titled “Detect different arrays”Returns false when arrays contain different elements.
Compare arrays of objects
Section titled “Compare arrays of objects”Supports shallow comparison of nested objects.
