export const cloneObject = (obj) => {
let newObj = {}
if (obj instanceof Array) {
newObj = []
}
for (var key in obj) {
let val = obj[key]
if (val === null) {
newObj[key] = null
} else {
newObj[key] = typeof val === 'object' ? cloneObject(val) : val
}
}
return newObj
}
网友评论