{"ScriptPreparationCode":"var 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 array: [1,2,3,4,5,6,7,8,9,0],\r\n nestedObject: {\r\n \ta: [{x: 1}, {x: 1}, {x: 1}],\r\n b: [{x: 1}, {x: 1}, {x: 1}],\r\n c: [{x: 1}, {x: 1}, {x: 1}]\r\n },\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;\r\n\r\nfunction deepFreeze(x) {\r\n\r\n if (!x || typeof x !== \u0027object\u0027) {\r\n \treturn x;\r\n }\r\n \r\n if (Array.isArray(x)) {\r\n \tconst y = [];\r\n for (let i = 0; i \u003C x.length; i\u002B\u002B) {\r\n y.push(deepFreeze(x[i]));\r\n }\r\n return Object.freeze(y);\r\n }\r\n \r\n const y = {};\r\n \r\n for (const key in x) {\r\n \tif (x.hasOwnProperty(key)) {\r\n y[key] = deepFreeze(x[key]);\r\n }\r\n }\r\n \r\n return Object.freeze(y);\r\n \r\n}\r\n\r\nfunction deepClone(x) {\r\n\r\n if (!x || typeof x !== \u0027object\u0027) {\r\n return x;\r\n }\r\n\r\n if (Array.isArray(x)) {\r\n const y = [];\r\n for (let i = 0; i \u003C x.length; i\u002B\u002B) {\r\n y.push(deepClone(x[i]));\r\n }\r\n return y;\r\n }\r\n\r\n const y = {};\r\n for (const key in x) {\r\n \tif (x.hasOwnProperty(key)) {\r\n y[key] = deepClone(x[key]); \r\n }\r\n }\r\n\r\n return y;\r\n\r\n}","TestCases":[{"Name":"Lodash cloneDeep","Code":"myCopy = _.cloneDeep(MyObject);","IsDeferred":false},{"Name":"custom deepFreeze()","Code":"myCopy = deepFreeze(MyObject)","IsDeferred":false},{"Name":"custom deepClone()","Code":"myCopy = deepClone(MyObject);","IsDeferred":false},{"Name":"JSON","Code":"myCopy = JSON.parse(JSON.stringify(MyObject));","IsDeferred":false}]}