0

I have two pieces of data i need to compare, which could consist of any combination of nested objects and arrays, for example:

let myObject = {
    a: [
        { x: 1, y: 2 },
        { x: 3, y: 4 }
    ],
    b: [1, 2, 3]
}

If i created a second object (say myObject2) defined exactly the same as above (in reality this second object is coming from localStorage), and check myObject == myObject2, it will be false. How can i compare this kind of data by value, such that if the property names/values and array elements all match, it returns true, otherwise false?

Lol Lol
  • 75
  • 6

0 Answers0