{"ScriptPreparationCode":"const array1 = [...Array(10000).keys()].map(key =\u003E ({\r\n id: key,\r\n value: \u0027array1\u0027\r\n}));\r\n\r\nconst array2 = [...Array(10000).keys()].map(key =\u003E ({\r\n id: key,\r\n value: \u0027array2\u0027\r\n}));\r\n\r\nconst combineArray = [...array1, ...array2]","TestCases":[{"Name":"Lodash","Code":"_.uniqBy(combineArray,\u0027id\u0027)","IsDeferred":false},{"Name":"JS using filter","Code":"const uniqBy = (array, key) =\u003E {\r\n const seen = new Set()\r\n return array.filter(item =\u003E {\r\n const keyValue = item[key]\r\n if (seen.has(keyValue)) {\r\n return false\r\n } else {\r\n seen.add(keyValue)\r\n return true\r\n }\r\n })\r\n}\r\nuniqBy(combineArray,\u0027id\u0027)","IsDeferred":false},{"Name":"JS using reduce","Code":"const uniqBy = (array,key) =\u003E {\r\n const _key = key ?? \u0027id\u0027\r\n return Object.values(\r\n array.reduce((acc, doc) =\u003E {\r\n if (!(doc[_key] in acc)) {\r\n acc[doc[_key]] = doc\r\n }\r\n return acc\r\n }, Object.create(null)),\r\n )\r\n}\r\n \r\nuniqBy(combineArray,\u0027id\u0027)","IsDeferred":false}]}