equalsShallow
One-level (shallow) object equality.
Two objects are equal when they share the exact same set of own
enumerable string keys and each pair of values satisfies strict equality
(===). No recursion: nested objects/arrays are compared by reference.
Falls back to strict equality when either input is null, undefined
or not an object \u2014 so primitives match if and only if they are ===.
Arrays are not supported; they always return false (unless identical
references). Use array/equalsShallow instead.
For recursive structural comparison use equalsDeep. For a diff structure use diff.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
objA | unknown | First value to compare |
objB | unknown | Second value to compare |
Returns
Section titled “Returns”boolean — true if values are shallowly equal, false otherwise.
Examples
Section titled “Examples”Compare two equal objects
Section titled “Compare two equal objects”Uses JSON.stringify for a fast comparison.
