js 深度拷贝

            function cloneObj(source, target) {
                var target = target || {}
                for (let key in source) {
                    if (source.hasOwnProperty(key)) {
                        if (typeof(source[key])== 'object') {
                            target[key]=source[key] instanceof Array?[]:{}
                            cloneObj(source[key],target[key])
                        } else {
                            target[key] = source[key]
                        }
                    }
                }
                return target
            }
原文地址:https://www.cnblogs.com/howhy/p/15785208.html