深拷贝方法


function deepClone(source) {
    if (source === null || typeof source !== 'object')
        return source;
    const target = source.constructor === Array ? [] : {}
    for (let key in source) {
        // 忽略从原型链上继承的属性
        if (source.hasOwnProperty(key)) {
            if (source[key] && typeof source[key] === 'object')
                target[key] = deepClone(source[key])
            else
                target[key] = source[key]
        }
    }
    return target
}