Assuming I have two copies of the same object exactly the same and one with some difference:
let uno = {"nombre": "Daniela", "edad": 24};
let dos = {"nombre": "Daniela", "edad": 24};
let tres = {"nombre": "Daniela", "edad": 25};
If I compare them as follows, they all give me false:
console.log(a == b); // False
console.log(a === b); // False
console.log(a == c); // False
console.log(a === c); // False
But I would like to know how to compare them so that when comparing the object a
with the object b
I get a true
.
If the order of properties on your objects is not going to change, you can use
JSON.stringify
like this:One way is to search the entire object A using its key , asking if object B also has that same key and then asking if that key is attached to the same value in both objects, I leave my code.