export function deepCopy (oldObj) {
  let typeString = obj => {
    var cons = Object.prototype.toString.call(obj).slice(8, -1)
    return (cons === 'Array' || cons === 'Object')
  }

  if (typeString(oldObj)) {
    var newObj = oldObj.constructor()
    for (let i in oldObj) {
      if (oldObj.hasOwnProperty(i)) {
        newObj[i] = typeString(oldObj[i]) ? deepCopy(oldObj[i]) : oldObj[i]
      }
    }
    return newObj
  } else {
    return oldObj
  }
}
