function deepClone (target,origin) { var target = target || {}; for (props in origin) { if (origin.hasOwnProperty(props)) { if ( typeof origin[props] === 'object') { target[props] = origin[props] instanceof Array ? [] : {} deepClone(target[props],origin[props]) } else { target[props] = origin[props] } } } return target; }