深拷贝

 function deepClone(source){

            var targetObj =  Array.isArray(source) === Array ? [] : {};

            for(var keys in source){

                if(source.hasOwnProperty(keys)){

                    if(source[keys] && typeof source[keys] === 'object'){
                        targetObj[keys] = deepClone(source[keys])

                    }else{

                        targetObj[keys]=source[keys]

                    }
                }
            }
            return targetObj
        }

 

posted @ 2023-02-24 10:46  钟文锋  阅读(10)  评论(0编辑  收藏  举报