对象数组深拷贝

export function deepCopy(source){
let target = Array.isArray( source ) ? [] : {}
for ( var k in source ) {
if ( typeof source[ k ] === 'object' ) {
target[ k ] = deepCopy( source[ k ] )
} else {
target[ k ] = source[ k ]
}
}
return target
}
posted @ 2019-08-15 15:24  Qu西亚  阅读(110)  评论(0编辑  收藏  举报