
大家好,又见面了,我是你们的朋友全栈君。
function deepCopy (obj, cache) {
if (cache === void 0) cache = []
if (obj === null || typeof obj !== 'object') return obj
var hit = find(cache, function (c) {
debugger
return c.original === obj
})
if (hit) return hit.copy
var copy = Array.isArray(obj) ? [] : {}
debugger
cache.push({
original: obj,
copy: copy
})
Object.keys(obj).forEach(key => {
debugger
copy[key] = this.deepCopy(obj[key], cache)
})
return copy
}
function find (list, f) {
debugger
return list.filter(f)[0]
}版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/186772.html原文链接:https://javaforall.cn