U
U
Urukhayy2018-02-10 08:43:18
JavaScript
Urukhayy, 2018-02-10 08:43:18

Are there ready-made libraries for finding object differences?

There is an object "A" consisting of properties, and each property can also be an object consisting of properties. And it can also be an array of properties, etc. And somewhere in the depths of this object "A" can change one property, and the state "B" will turn out. Is there such a library that will receive the object "A" and "B" as input, and return all the differences between them? Even deep in the array.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
Urukhayy, 2018-02-13
@Urukhayy

https://gist.github.com/Yimiprod/7ee176597fef230d1451

A
Andrey Tsvetkov, 2018-02-10
@yellow79

Whether they are the same or not, you can check this.

function isEqual(A, B) {
    return JSON.stringify(A) === JSON.stringify(B);
}

As for the differences, it's not entirely clear in what form you want to get them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question