1
0
Fork 0
forked from svrjs/svrjs

Optimize deepClone function even more

This commit is contained in:
Dorian Niemiec 2024-08-27 22:51:41 +02:00
parent c73ce5d9f7
commit 67d9ae524c

View file

@ -27,12 +27,10 @@ function deepClone(obj) {
_objectsArray.push(obj);
_clonesArray.push(clone);
Object.keys(obj).forEach((key) => {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
clone[key] =
typeof obj[key] !== "object" || obj[key] === null
? obj[key]
: recurse(obj[key], _objectsArray, _clonesArray);
}
});
}
return clone;