实现一 : JSON序列化与反序列化
var a = {
    b:1,
    c:[1,2,3],
    d:{c1:'cccc1',c2:'cccc2'}
}
var str = JSON.parse(JSON.string(a))
缺点:
- 反序列化深拷贝不支持函数
 - 不支持undefined
 - 不支持引用
 - 不支持Date
 - 不支持正则表达式
 - 不支持symbol
 
实例
// 不支持引用
var a = {
    name:'a'
}
a.self = a;
var str = JSON.parse(JSON.string(a)) //error
实现二 : 递归克隆
function deepClone(source){
    if(source instanceof Object){
        if(source instanceof Array){
            const dist = new Array();
            for(let key in source){
                dist[key] = deepClone(source[key])
            }
            return dist
        }else if(source instanceof Function){
            const dist = function(){
                return source.apply(this,arguments)
            }
            for(let key in source){
                dist[key] = deepClone(source[key])
            }
            return dist;
        }else{
            const dist = new Object();
            for(let key in source){
                dist[key] = deepClone(source[key])
            }
            return dist
        }
    }
    return source
}
module.exports = deepClone;