I have two JSON objects like so:
var obj1 = {a: "apple", b: "banana", c: "carrot"}
var obj2 = {a: "apple", e: “egg” b: "banana", c: "carrot", d: "dog"}
I want to be able to have a Boolean check comparing the two objects without having to remove data from either one. For example, if I were to use the data above, the Boolean check should return true because the values of the keys that are in both objects match.
However, lets say obj1 stays the same but obj2 is the following:
var obj1 = {a: "apple", b: "banana", c: "carrot"}
var obj2 = {a: "ant", e: “egg” b: "banana", c: "carrot", d: "dog"}
With this data, it should return false because the a key's value is not matching even though other fields are matching and some fields are not present in both objects.
Any ideas? I would prefer to use Lodash since they have a quality library. Originally was trying to use _.isEqual(obj1, obj2) but it doesn't work for my exact needs.