function diff(obj1, obj2) {
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
return false;
}
for (let key in obj1) {
const t1 = obj1[key] instanceof Object;
const t2 = obj2[key] instanceof Object;
if (t1 && t2) {
return diff(obj1[key], obj2[key]);
} else if (obj1[key] !== obj2[key]) {
return false;
}
}
return true;
}
03-02
5641
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-04
2984
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-08
3357
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)