1
0
Fork 0
forked from svrjs/svrjs

Fix the deepClone function

This commit is contained in:
Dorian Niemiec 2024-08-27 22:52:36 +02:00
parent 67d9ae524c
commit 63633d1de1

View file

@ -20,7 +20,10 @@ function deepClone(obj) {
_objectsArray.push(obj); _objectsArray.push(obj);
_clonesArray.push(clone); _clonesArray.push(clone);
obj.forEach((item, index) => { obj.forEach((item, index) => {
clone[index] = recurse(item, _objectsArray, _clonesArray); clone[index] =
typeof item !== "object" || item === null
? item
: recurse(item, _objectsArray, _clonesArray);
}); });
} else { } else {
clone = {}; clone = {};