mirror of
https://github.com/randyjc/Rahoot.git
synced 2026-03-13 20:15:35 +01:00
21 lines
347 B
JavaScript
21 lines
347 B
JavaScript
const deepClone = (obj) => {
|
|
if (obj === null || typeof obj !== "object") {
|
|
return obj
|
|
}
|
|
|
|
if (Array.isArray(obj)) {
|
|
return obj.map(deepClone)
|
|
}
|
|
|
|
const clonedObj = {}
|
|
for (const key in obj) {
|
|
if (Object.hasOwn(obj, key)) {
|
|
clonedObj[key] = deepClone(obj[key])
|
|
}
|
|
}
|
|
|
|
return clonedObj
|
|
}
|
|
|
|
export default deepClone
|