How to judge the difference between two objects with different nesting levels?

now there is a requirement to judge the difference between the two objects, and awkwardly, there is only a difference in the nesting level between the two objects:: > _ <:

var a = {
      1:{
        2:{
          3:"3"
        }
      }
    }
var b = {
      4:{
        5:"5"
      }
    }
The a, b, c attributes of

objects are all indefinite, and the number is also indefinite

.

is there a simple operation to determine which object it is?

Mar.23,2021

does not quite understand your requirements, is to determine whether two objects have the same depth? Or judge whether two objects are not equal
1. If you just judge the depth, then iterate through it recursively, get the depth of each object, and then compare
2. If you are judging whether two objects are equal, it is also a recursive traversal, and whether each layer is equal

.
Menu