SOURCE

function deepClone(obj) {
    if (typeof obj !== 'object' || String(obj) === 'null') return obj
    const res = Object.prototype.toString.call(obj).split(' ')[1]
    const type = res.substring(0, res.length - 1)
    // console.log(type)
    const result = type === 'Array' ? [] : {}
    // if (type === 'Array') {
    for (let key in obj) {
        result[key] = deepClone(obj[key])
    }

    // }
    return result
}
let arr = [1, 2, [3, 7]]
let o1 = { a: 8, b: { c: 89 } }
let a = deepClone(arr)
let b = deepClone(o1)
a[1] = 90
console.log(arr,a)
b.b.c = 99999
console.log(o1,b)
console 命令行工具 X clear

                    
>
console