{"ScriptPreparationCode":"var obj = {\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.parse(JSON.stringify())","Code":"JSON.parse(JSON.stringify(obj));","IsDeferred":false},{"Name":"structuredClone()","Code":"structuredClone(obj);","IsDeferred":false},{"Name":"fast_deep_clone()","Code":"const fast_deep_clone = (obj) =\u003E {\r\n function cloneArray(a, fn) {\r\n var keys = Object.keys(a);\r\n var a2 = new Array(keys.length)\r\n for (const key of keys) {\r\n var k = keys[key];\r\n var cur = a[k];\r\n if (typeof cur !== \u0027object\u0027 || cur === null) {\r\n a2[k] = cur;\r\n } else {\r\n a2[k] = fn(cur);\r\n }\r\n }\r\n return a2;\r\n }\r\n\r\n if (typeof obj !== \u0027object\u0027 || obj === null) return obj;\r\n if (obj instanceof Date) return new Date(obj);\r\n if (Array.isArray(obj)) return cloneArray(obj, fast_deep_clone);\r\n if (obj.toString() !== \u0027[object Object]\u0027) {\r\n return obj.toString();\r\n }\r\n\r\n let value, key;\r\n const keys = Object.keys(obj);\r\n const outObject = {};\r\n \r\n for (key of keys) {\r\n if (key) {\r\n value = obj[key];\r\n outObject[key] = fast_deep_clone(value);\r\n }\r\n }\r\n \r\n return outObject;\r\n};\r\n\r\nfast_deep_clone(obj);","IsDeferred":false}]}