This commit is contained in:
Carlos Montiers A
2019-08-21 16:51:29 -04:00
committed by Angelos Chalaris
parent c913e38cf6
commit a26783ea6c

View File

@ -11,6 +11,11 @@ Use `Object.keys()` and `Array.prototype.forEach()` to determine which key-value
```js
const deepClone = obj => {
let type = typeof obj;
let isAssignable = type === "function" || type === "object" && !!obj;
if (!isAssignable) {
return obj;
}
let clone = Object.assign({}, obj);
Object.keys(clone).forEach(
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])