Files
Rahoot/socket/utils/deepClone.js
2025-09-28 12:58:51 +02:00

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