I have two nested objects obj1 and obj2 and I want to compare them and the recursively return an object that for each nested key has a equality-like boolean flag
So for a given obj1 like
obj1 = { prop1: 1, prop2: "foo", prop3: { prop4: 2, prop5: "bar" } } and the obj2 like
obj2 = { prop1: 3, prop2: "foo", prop3: { prop4: 2, prop5: "foobar" }, prop6: "new" } it should return
equality = { prop1: false, prop2: true, prop3 : { prop4: true, prop5: false }, prop6: false } If an object has a new property, like obj2.prop6, then the equality will be equality.prop6 = false.
For non-nested object a simple keys comparison solutions is here Get the property of the difference between two objects in javascript While to recursively compare nested objects it is showed here JavaScript: Deep comparison recursively: Objects and properties
false. Updating with this point. Thank you.