1 function deepClone(origin, target) { 2 var target = target || {}, 3 toStr = Object.prototype.toString, 4 arrStr = "[object Array]"; 5 6 for (var prop in origin) { 7 if (origin.hasOwnProperty(prop)) { 9 if (origin[prop] !== null && typeof (origin[prop]) == 'object') { 11 target[prop] = toStr.call(origin[prop]) == arrStr ? [] : {}; 13 deepClone(origin[prop], target[prop]) 14 }else { 15 target[prop] = origin[prop] 16 } 17 } 18 } 19 return target; 20 }