克隆

# 克隆

深克隆

        function deepClone(target) {
            if (!target || typeof target != 'object') return null;
            var copyTarget = Object.prototype.toString.call(target) == '[object Array]'																   ? new Array(target.length) : {};
            for (var prop in target) {
                if (target.hasOwnProperty(prop)) {
                    if (typeof target[prop] == 'object') {
                        copyTarget[prop] = deepClone(target[prop])
                    } else {
                        copyTarget[prop] = target[prop];
                    }
                }
            }
            return copyTarget;
        }