{"ScriptPreparationCode":"var Books = [\r\n {\r\n id: 1,\r\n title: \u0027Great Book\u0027,\r\n price: null,\r\n available: true\r\n },\r\n {\r\n\u00A0 \u00A0 id: 2,\r\n\u00A0 \u00A0 title: \u0027Another Great Book\u0027,\r\n\u00A0 \u00A0 price: 11.99,\r\n available: false\r\n\u00A0 },\r\n {\r\n\u00A0 \u00A0 id: 3,\r\n\u00A0 \u00A0 title: \u0027Another Great Book\u0027,\r\n\u00A0 \u00A0 price: 9.99,\r\n available: true\r\n\u00A0 },\r\n {\r\n\u00A0 \u00A0 id: 4,\r\n\u00A0 \u00A0 title: \u0027Another Great Book\u0027,\r\n\u00A0 \u00A0 price: null,\r\n available: true\r\n\u00A0 },\r\n {\r\n\u00A0 \u00A0 id: 5,\r\n\u00A0 \u00A0 title: \u0027Another Great Book\u0027,\r\n\u00A0 \u00A0 price: 13.99,\r\n available: false\r\n\u00A0 } \r\n];\r\n\r\nvar clone = null;\r\n\r\nvar hasOwn = Object.prototype.hasOwnProperty;\r\n\r\nfunction deepClone (source) {\r\n\r\n if (source instanceof Date) return new Date(source.getTime())\r\n\r\n if (Array.isArray(source)) {\r\n const clone = []\r\n let i = source.length\r\n\r\n while (i--) {\r\n const value = source[i]\r\n clone[i] = (value !== null \u0026\u0026 typeof value === \u0027object\u0027)\r\n ? deepClone(value)\r\n : value\r\n }\r\n\r\n return clone\r\n }\r\n\r\n const clone = {}\r\n\r\n for (const key in source) {\r\n if ({}.hasOwnProperty.call(source, key)) {\r\n const value = source[key]\r\n \r\n clone[key] = (value !== null \u0026\u0026 typeof value === \u0027object\u0027)\r\n ? deepClone(value)\r\n : value\r\n }\r\n }\r\n\r\n return clone\r\n}","TestCases":[{"Name":"Lodash CloneDeep","Code":"clone = _.cloneDeep(Books);","IsDeferred":false},{"Name":"Json Clone","Code":"clone = JSON.parse(JSON.stringify(Books));","IsDeferred":false},{"Name":"deepClone","Code":"clone = deepClone(Books);","IsDeferred":false}]}