{"ScriptPreparationCode":"var deepCopyObject = (inObject) =\u003E {\r\n if (inObject instanceof Date) return inObject\r\n\r\n if (inObject instanceof Set) return new Set(inObject)\r\n\r\n if (inObject instanceof Map) return new Map(inObject)\r\n\r\n if (typeof inObject !== \u0027object\u0027 || inObject === null) {\r\n return inObject // Return the value if inObject is not an object\r\n }\r\n\r\n // Create an array or object to hold the values\r\n const outObject = Array.isArray(inObject) ? [] : {}\r\n\r\n Object.keys(inObject).forEach((key) =\u003E {\r\n const value = inObject[key]\r\n\r\n // Recursively (deep) copy for nested objects, including arrays\r\n outObject[key] = typeof value === \u0027object\u0027 \u0026\u0026 value !== null ? deepCopyObject(value) : value\r\n })\r\n\r\n return outObject\r\n}\r\n\r\nfunction deepCopyObjectSimple(inObject) {\r\n if (typeof inObject !== \u0027object\u0027 || inObject === null) {\r\n return inObject;\r\n }\r\n\r\n const outObject = Array.isArray(inObject) ? [] : {};\r\n\r\n for (const key in inObject) {\r\n const value = inObject[key];\r\n outObject[key] = (typeof value === \u0027object\u0027 \u0026\u0026 value !== null) ? deepCopyObjectSimple(value) : value;\r\n }\r\n\r\n return outObject;\r\n}\r\nvar MyObject = {\r\n description: \u0027Creates a deep copy of source, which should be an object or an array.\u0027,\r\n myNumber: 123456789,\r\n myBoolean: true,\r\n jayson: {\r\n stringify: \u0027JSON.stringify() method converts a JavaScript value to a JSON string....\u0027,\r\n parse: \u0027JSON.parse() method parses a JSON string...\u0027\r\n }\r\n};\r\n\r\nvar myCopy = null;","TestCases":[{"Name":"JSON.stringify","Code":"myCopy = JSON.parse(JSON.stringify(MyObject));","IsDeferred":false},{"Name":"structuredClone","Code":"myCopy = structuredClone(MyObject);","IsDeferred":false},{"Name":"deepCopyObject","Code":"myCopy = deepCopyObject(MyObject);","IsDeferred":false},{"Name":"deepCopyObjectSimple","Code":"myCopy = deepCopyObjectSimple(MyObject);","IsDeferred":false}]}