0π
β
It is more like you want to know the delta between two exactly same javascript structures. When I want to find out delta I generally use deep-object-diff. It has multiple difference functions.
From the example from npmjs:
const lhs = { foo: { bar: { a: ['a', 'b'], b: 2, c: ['x', 'y'], e: 100 // deleted } }, buzz: 'world' }; const rhs = { foo: { bar: { a: ['a'], // index 1 ('b') deleted b: 2, // unchanged c: ['x', 'y', 'z'], // 'z' added d: 'Hello, world!' // added } }, buzz: 'fizz' // updated }; console.log(detailedDiff(lhs, rhs)); /* { added: { foo: { bar: { c: { '2': 'z' }, d: 'Hello, world!' } } }, deleted: { foo: { bar: { a: { '1': undefined }, e: undefined } } }, updated: { buzz: 'fizz' } } */
Source:stackexchange.com