```var deepCopy = function(obj) {
if (typeof obj !== 'object') return obj
var newObj = (Object.prototype.toString.call(obj) === '[object Array]') ? [] : {}
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
newObj[key] = (typeof obj[key] !== 'object') ? obj[key]: deepCopy(obj[key])
}
}
return newObj
}
```