equalsShallow
Positional, one-level (shallow) array equality.
Two arrays are equal when they have the same length and each pair of
elements at the same index satisfies strict equality (===). No
recursion: nested arrays/objects are compared by reference.
For recursive structural comparison use equalsDeep. For order-independent comparison use equalsUnordered.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
arrA | readonly T[] | First array to compare |
arrB | readonly T[] | Second array to compare |
Returns
Section titled “Returns”boolean — true if every element matches by === at the same index, false otherwise.
Examples
Section titled “Examples”Compare identical arrays
Section titled “Compare identical arrays”Uses JSON.stringify for a fast shallow comparison.
Detect order differences
Section titled “Detect order differences”Unlike equals, equalsShallow is order-sensitive.
