{"ScriptPreparationCode":"var arr1 = Array(10000).fill(null).map((_, i) =\u003E ({\r\n id: i,\r\n label: \u0060number ${i}\u0060\r\n}));\r\nvar arr2 = Array(10000).fill(null).map((_, i) =\u003E ({\r\n id: i*2,\r\n label: \u0060number ${i*2}\u0060\r\n}));","TestCases":[{"Name":"Merge using object (forEach)","Code":"function toMap(arr, key) {\r\n const result = {};\r\n\r\n arr.forEach((entity) =\u003E {\r\n const k = entity[key];\r\n result[k] = entity;\r\n });\r\n return result;\r\n}\r\n\r\nconst first = toMap(arr1, \u0027id\u0027);\r\nconst second = toMap(arr2, \u0027id\u0027);\r\nconst combined = {...first, ...second};","IsDeferred":false},{"Name":"Using Map","Code":"function toMap(arr, key) {\r\n return new Map(arr.map(item =\u003E ([item[key], item])));\r\n}\r\n\r\nconst first = toMap(arr1, \u0027id\u0027);\r\nconst second = toMap(arr2, \u0027id\u0027);\r\nconst combined = new Map([...arr1, ...arr2]);","IsDeferred":false}]}