{"ScriptPreparationCode":"\r\nfunction cloneDeep(obj) {\r\n if (typeof obj !== \u0027object\u0027 || obj === null) return obj;\r\n let cloned, i;\r\n if (obj instanceof Date) {\r\n cloned = new Date(obj.getTime());\r\n return cloned;\r\n }\r\n if (obj instanceof Array) {\r\n let l;\r\n cloned = [];\r\n for (i = 0, l = obj.length; i \u003C l; i\u002B\u002B) cloned[i] = cloneDeep(obj[i]);\r\n return cloned;\r\n }\r\n cloned = {};\r\n for (i in obj) if (obj.hasOwnProperty(i)) cloned[i] = cloneDeep(obj[i]);\r\n return cloned;\r\n}","TestCases":[{"Name":"Using the spread operator","Code":"const car = {type:\u0022Fiat\u0022, model:\u0022500\u0022, color:\u0022white\u0022};\r\nlet carCopy = {\r\n\t...car,\r\n \ttype:\u0022Ford\u0022\r\n};","IsDeferred":false},{"Name":"Using cloneDeep","Code":"const car = {type:\u0022Fiat\u0022, model:\u0022500\u0022, color:\u0022white\u0022};\r\nlet carCopy = cloneDeep(car)\r\ncarCopy.type = \u0022Ford\u0022","IsDeferred":false}]}