The isEqual function from Lodash can be used to compare two values and determine if they are equivalent. This function uses a deep comparison to compare nested objects, arrays, and primitive values.
To use isEqual, first, import it from the Lodash library:
index.tsx43 chars2 lines
Then you can call isEqual passing the objects you want to compare:
index.tsx115 chars5 linesIn this example, isEqual compares obj1 and obj2 and returns true because both objects have the same properties with the same values.
You can also use isEqual to compare arrays:
index.tsx109 chars5 linesIn this case, isEqual returns true because both arrays have the same elements with the same values.
Note that isEqual returns true only if the objects or arrays being compared have the same structure and the same values. If the objects or arrays have different types or different keys or elements, isEqual will return false.
index.tsx70 chars2 lines
gistlibby LogSnag