Update deepClone.md

We missed that the clone length wasn't there. This fixes the issue
This commit is contained in:
Robert Mennell
2018-05-13 23:07:44 -07:00
committed by GitHub
parent e8056e9efb
commit aaf6a20236

View File

@ -12,7 +12,7 @@ const deepClone = obj => {
Object.keys(clone).forEach(
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
);
return Array.isArray(obj) ? Array.from(clone) : clone;
return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone;
};
```