- 对象深拷贝
Object.assign({},对象1,对象2,对象3....)
- 数组深拷贝
数组.map((i,t) => t)
- deepClone
深克隆-object,array
// 深克隆-object,array
deepClone(obj) {
let objClone = Array.isArray(obj) ? [] : {};
if (obj && typeof obj === 'object') {
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
obj[key] && typeof obj[key] === 'object'
? (objClone[key] = deepClone(obj[key]))
: (objClone[key] = obj[key]);
}
}
}
return objClone;
}