{"ScriptPreparationCode":null,"TestCases":[{"Name":"Using the spread operator","Code":"const firstObject = { a: \u0027a\u0027, b: \u0027b\u0027, c: \u0027c\u0027, d: \u0027d\u0027, e: \u0027e\u0027, f: \u0027f\u0027, g: \u0027g\u0027 }\r\nconst secondObject = { 0: 0, 1: 1, 2: 2, 3: 3, 4: \u00274\u0027, 5: \u00275\u0027, 6: \u00276\u0027, 7: \u00277\u0027 }\r\nconst conditionState = Boolean(Object.keys(secondObject).length)\r\n\r\nconst finalObject = {\r\n\t...firstObject,\r\n \t...(conditionState ? secondObject : {}),\r\n \t...(conditionState ? secondObject : {}),\r\n \t...(!conditionState ? secondObject : {})\r\n};","IsDeferred":false},{"Name":"Using Object.assign","Code":"const firstObject = { a: \u0027a\u0027, b: \u0027b\u0027, c: \u0027c\u0027, d: \u0027d\u0027, e: \u0027e\u0027, f: \u0027f\u0027, g: \u0027g\u0027 }\r\nconst secondObject = { 0: 0, 1: 1, 2: 2, 3: 3, 4: \u00274\u0027, 5: \u00275\u0027, 6: \u00276\u0027, 7: \u00277\u0027 }\r\nconst conditionState = Boolean(Object.keys(secondObject).length)\r\n\r\nconst finalObject = Object.assign(firstObject, conditionState \u0026\u0026 secondObject, conditionState \u0026\u0026 secondObject, !conditionState \u0026\u0026 secondObject);","IsDeferred":false},{"Name":"Using mutation","Code":"const firstObject = { a: \u0027a\u0027, b: \u0027b\u0027, c: \u0027c\u0027, d: \u0027d\u0027, e: \u0027e\u0027, f: \u0027f\u0027, g: \u0027g\u0027 }\r\nconst secondObject = { 0: 0, 1: 1, 2: 2, 3: 3, 4: \u00274\u0027, 5: \u00275\u0027, 6: \u00276\u0027, 7: \u00277\u0027 }\r\nconst conditionState = Boolean(Object.keys(secondObject).length)\r\n\r\nconst finalObject = {\r\n a: firstObject.a,\r\n b: firstObject.b,\r\n c: firstObject.c,\r\n d: firstObject.d,\r\n e: firstObject.e,\r\n f: firstObject.f,\r\n g: firstObject.g\r\n}\r\n\r\nif (conditionState) {\r\n\tfinalObject[0] = secondObject[0]\r\n\tfinalObject[1] = secondObject[1]\r\n\tfinalObject[2] = secondObject[2]\r\n\tfinalObject[3] = secondObject[3]\r\n\tfinalObject[4] = secondObject[4]\r\n\tfinalObject[5] = secondObject[5]\r\n\tfinalObject[6] = secondObject[6]\r\n\tfinalObject[7] = secondObject[7]\r\n}\r\n\r\nif (conditionState) {\r\n\tfinalObject[0] = secondObject[0]\r\n\tfinalObject[1] = secondObject[1]\r\n\tfinalObject[2] = secondObject[2]\r\n\tfinalObject[3] = secondObject[3]\r\n\tfinalObject[4] = secondObject[4]\r\n\tfinalObject[5] = secondObject[5]\r\n\tfinalObject[6] = secondObject[6]\r\n\tfinalObject[7] = secondObject[7]\r\n}\r\n\r\nif (!conditionState) {\r\n\tfinalObject[0] = secondObject[0]\r\n\tfinalObject[1] = secondObject[1]\r\n\tfinalObject[2] = secondObject[2]\r\n\tfinalObject[3] = secondObject[3]\r\n\tfinalObject[4] = secondObject[4]\r\n\tfinalObject[5] = secondObject[5]\r\n\tfinalObject[6] = secondObject[6]\r\n\tfinalObject[7] = secondObject[7]\r\n}","IsDeferred":false},{"Name":"Using iterable mutation","Code":"const firstObject = { a: \u0027a\u0027, b: \u0027b\u0027, c: \u0027c\u0027, d: \u0027d\u0027, e: \u0027e\u0027, f: \u0027f\u0027, g: \u0027g\u0027 }\r\nconst secondObject = { 0: 0, 1: 1, 2: 2, 3: 3, 4: \u00274\u0027, 5: \u00275\u0027, 6: \u00276\u0027, 7: \u00277\u0027 }\r\nconst conditionState = Boolean(Object.keys(secondObject).length)\r\n\r\nconst finalObject = {}\r\n\r\nfor (const key in finalObject) {\r\n finalObject[key] = firstObject[key]\r\n}\r\n\r\nif (conditionState) {\r\n\tfor (const key in secondObject) {\r\n finalObject[key] = secondObject[key]\r\n }\r\n}\r\n\r\nif (conditionState) {\r\n\tfor (const key in secondObject) {\r\n finalObject[key] = secondObject[key]\r\n }\r\n}\r\n\r\nif (!conditionState) {\r\n\tfor (const key in secondObject) {\r\n finalObject[key] = secondObject[key]\r\n }\r\n}","IsDeferred":false}]}