0

I have a javascript object which can be updated or patched and i want to be able to know by comparing the original which is object p and object p2 which is a copy of object p to know which elements were updated. So in this case i want to be able to compare the two to know if there has been some difference if so, then i grab the id's of the changed ones into a something like; edited = [1, 3].

This is the main object.

var p = {
    "1": "value1",
    "2": "value2",
    "3": "value3"
};

Let's say it has been copied and updated to:

var p2 = {
"1": "changed",
"2": "value2",
"3": "changed"
};
  • Does this answer your question? [How to determine equality for two JavaScript objects?](https://stackoverflow.com/questions/201183/how-to-determine-equality-for-two-javascript-objects) – Christopher Oct 09 '22 at 23:24
  • You've already asked this question. – evolutionxbox Oct 09 '22 at 23:26
  • @Christopher Do any of those answers return the list of changed properties? – Barmar Oct 09 '22 at 23:30
  • This solved my problem. https://stackoverflow.com/questions/46930387/get-the-property-of-the-difference-between-two-objects-in-javascript – anonym Jnr Oct 10 '22 at 00:53

0 Answers0