SOURCE

function isEqual(obj1, obj2){
    if(typeof obj1!=="object" || typeof obj2!=="object" || obj1==="null" || obj2==="null"){
        throw new Error("arguments error, must be object")
    }
    let key1 = Object.keys(obj1)
    let key2 = Object.keys(obj2)
    if(key1.length!==key2.length) return false
    // let flag = true
    for(let t of key1){
        // console.log((obj1[t],obj2[t]))
        if(typeof obj1[t]==='object'){
            if(typeof obj2[t]!=='object'){
                return false
            }else{
                if(!isEqual(obj1[t],obj2[t])) return false
            }
        }else{
            if(obj1[t]!==obj2[t]){
                return false
            }
        }
    }
    return true
}
// test region
let obj1 = {
    a:1,
    b:2,
    c:{
        a:10,
        b:25
    },
    d:[1,2]
}

let obj2 = {
    b:2,
    a:1,
    c:{
        a:10,
        b:25
    },
    d:[1,2,3]
}

console.log(isEqual(obj1, obj2))
console 命令行工具 X clear

                    
>
console