core3-utils

@wixc3/common on Github

Home > @wixc3/common > same

same() function

Deep comparison of two objects

Signature:

export declare function same<T>(a: T, b: T, unordered?: boolean): boolean;

Parameters

Parameter Type Description
a T
b T
unordered boolean _(Optional)_ \[false\] Note: relevant only in array like iterables. objects, sets and maps are \*never checked for order\* of entries

Returns:

boolean

Remarks

items are “the same” if:

Example

same({a:1, b:2},{b:2, a:1}) // => true
same(new Map([['a',1],['b',2]]), new Map([['b',2],['a',1]])) // => true
same(new Map([[{a:1},{b:1}]]]), new Map([[{a:1},{b:1}]]])) // => true
same([0,1], [1,0]) // => false
same([0,1], [1,0], true) // => true