function deepClone(org, tar) {
var tar = tar || {},
toStr = Object.prototype.toString,
arrType = '[object Array]';
for(var key in org) {
if(org.hasOwnProperty(key)) {
if(typeof org[key] === 'object' && org[key] !== null) {
tar[key] = toStr.call(org[key]) === arrType ? [] : {}
deepClone(org[key], tar[key])
} else {
tar[key] = org[key]
}
}
}
}
深拷贝方法实现
最新推荐文章于 2024-09-03 16:07:32 发布