{"ScriptPreparationCode":"var arr = [\r\n {\r\n id: 123,\r\n name: \u0022abc\u0022,\r\n },\r\n {\r\n id: 1234,\r\n name: \u0022abcd\u0022,\r\n },\r\n {\r\n id: 123,\r\n name: \u0022abc\u0022,\r\n },\r\n {\r\n id: 4321,\r\n name: \u0027dcba\u0027,\r\n },\r\n];\r\n\r\nvar key=\u0027id\u0027;","TestCases":[{"Name":"Pure JS: map","Code":"var indexArray = [];\r\nvar newArray = arr.map(a =\u003E { if (indexArray.indexOf(a[key]) \u003C 0) { indexArray.push(a[key]); return a; }; return -1; }).filter(a =\u003E a != -1);","IsDeferred":false},{"Name":"Pure JS: forEach","Code":"var indexArray = [];\r\nvar newArray = [];\r\narr.forEach(a =\u003E { if (indexArray.indexOf(a[key]) \u003C 0) { indexArray.push(a[key]); newArray.push(a); }});","IsDeferred":false},{"Name":"Lodash: uniqBy","Code":"var newArray = _.uniqBy(arr, key);","IsDeferred":false}]}