{"ScriptPreparationCode":null,"TestCases":[{"Name":"Spread operator (...)","Code":"// base object\r\nconst base = {\r\n\tfirstName: \u0027John\u0027,\r\n lastName: \u0027Doe\u0027,\r\n size: 170,\r\n birthDate: new Date(1985, 0,15),\r\n married: true,\r\n address: {\r\n \tstreet: \u00272 av Victor Hugo\u0027,\r\n country: \u0027FR\u0027,\r\n },\r\n childrens: [\r\n \t{\r\n \tname: \u0027Paul\u0027,\r\n age: 8,\r\n },\r\n ],\r\n functions: [],\r\n};\r\nconst copy = { ...base };","IsDeferred":false},{"Name":"JSON.parse(JSON.stringify())","Code":"// base object\r\nconst base = {\r\n\tfirstName: \u0027John\u0027,\r\n lastName: \u0027Doe\u0027,\r\n size: 170,\r\n birthDate: new Date(1985, 0,15),\r\n married: true,\r\n address: {\r\n \tstreet: \u00272 av Victor Hugo\u0027,\r\n country: \u0027FR\u0027,\r\n },\r\n childrens: [\r\n \t{\r\n \tname: \u0027Paul\u0027,\r\n age: 8,\r\n },\r\n ],\r\n functions: [],\r\n};\r\nconst copy = JSON.parse(JSON.stringify(base));","IsDeferred":false},{"Name":"Custom function","Code":"function clone(aObject) {\r\n // Prevent undefined objects\r\n // if (!aObject) return aObject;\r\n\r\n let bObject = Array.isArray(aObject) ? [] : {};\r\n\r\n let value;\r\n for (const key in aObject) {\r\n\r\n // Prevent self-references to parent object\r\n // if (Object.is(aObject[key], aObject)) continue;\r\n\r\n value = aObject[key];\r\n\r\n bObject[key] = (typeof value === \u0022object\u0022) ? clone(value) : value;\r\n }\r\n\r\n return bObject;\r\n};\r\n// base object\r\nconst base = {\r\n\tfirstName: \u0027John\u0027,\r\n lastName: \u0027Doe\u0027,\r\n size: 170,\r\n birthDate: new Date(1985, 0,15),\r\n married: true,\r\n address: {\r\n \tstreet: \u00272 av Victor Hugo\u0027,\r\n country: \u0027FR\u0027,\r\n },\r\n childrens: [\r\n \t{\r\n \tname: \u0027Paul\u0027,\r\n age: 8,\r\n },\r\n ],\r\n functions: [],\r\n};\r\nconst copy = clone(base);","IsDeferred":false},{"Name":"Lodash.cloneDeep()","Code":"// base object\r\nconst base = {\r\n\tfirstName: \u0027John\u0027,\r\n lastName: \u0027Doe\u0027,\r\n size: 170,\r\n birthDate: new Date(1985, 0,15),\r\n married: true,\r\n address: {\r\n \tstreet: \u00272 av Victor Hugo\u0027,\r\n country: \u0027FR\u0027,\r\n },\r\n childrens: [\r\n \t{\r\n \tname: \u0027Paul\u0027,\r\n age: 8,\r\n },\r\n ],\r\n functions: [],\r\n};\r\nconst copy = _.cloneDeep(base);","IsDeferred":false},{"Name":"jQuery.extend(true)","Code":"// base object\r\nconst base = {\r\n\tfirstName: \u0027John\u0027,\r\n lastName: \u0027Doe\u0027,\r\n size: 170,\r\n birthDate: new Date(1985, 0,15),\r\n married: true,\r\n address: {\r\n \tstreet: \u00272 av Victor Hugo\u0027,\r\n country: \u0027FR\u0027,\r\n },\r\n childrens: [\r\n \t{\r\n \tname: \u0027Paul\u0027,\r\n age: 8,\r\n },\r\n ],\r\n functions: [],\r\n};\r\nconst copy = jQuery.extend(true, {}, base);","IsDeferred":false},{"Name":"structuredClone()","Code":"// base object\r\nconst base = {\r\n\tfirstName: \u0027John\u0027,\r\n lastName: \u0027Doe\u0027,\r\n size: 170,\r\n birthDate: new Date(1985, 0,15),\r\n married: true,\r\n address: {\r\n \tstreet: \u00272 av Victor Hugo\u0027,\r\n country: \u0027FR\u0027,\r\n },\r\n childrens: [\r\n \t{\r\n \tname: \u0027Paul\u0027,\r\n age: 8,\r\n },\r\n ],\r\n functions: [],\r\n};\r\nconst copy = structuredClone(base);","IsDeferred":false}]}