{"ScriptPreparationCode":"var vectors = Array.from({\r\n length: 500\r\n}, () =\u003E ({\r\n name: faker.name.firstName(),\r\n surname: faker.name.lastName(),\r\n age: faker.random.number({\r\n min: 1,\r\n max: 100\r\n }),\r\n country: faker.address.country()\r\n}));\r\n\r\nconsole.log(vectors.slice(0, 10)); // Just to verify by logging the first 10 objects","TestCases":[{"Name":"Vanilla JS","Code":"const projects = Array.from(new Set(\r\n vectors\r\n .filter(p =\u003E p.country === \u0022India\u0022 \u0026\u0026 p.country !== undefined)\r\n .map(p =\u003E String(p.country))\r\n));\r\n","IsDeferred":false},{"Name":"Lodash","Code":"const uniqueVectors = _.uniqBy(vectors, \u0027country\u0027);\r\nconst definedCountries = _.filter(uniqueVectors, p =\u003E p.country === \u0022India\u0022 \u0026\u0026 p.country !== undefined);\r\nconst projects = _.map(definedCountries, p =\u003E String(p.country));","IsDeferred":false},{"Name":"for each","Code":"const countrySet = new Set();\r\n\r\nvectors.forEach(p =\u003E {\r\n if (p.country === \u0022India\u0022 \u0026\u0026 p.country !== undefined) {\r\n countrySet.add(String(p.country));\r\n }\r\n});\r\n\r\nconst projects = Array.from(countrySet);\r\n","IsDeferred":false},{"Name":"for loop","Code":"const countrySet = new Set();\r\n\r\nfor (let i = 0; i \u003C vectors.length; i\u002B\u002B) {\r\n if (vectors[i].country === \u0022India\u0022 \u0026\u0026 vectors[i].country !== undefined) {\r\n countrySet.add(String(vectors[i].country));\r\n }\r\n}\r\n\r\nconst projects = Array.from(countrySet);\r\n","IsDeferred":false},{"Name":"new Set","Code":"const countrySet = new Set();\r\n\r\nfor (let vector of vectors) {\r\n if (vector.country === \u0022India\u0022 \u0026\u0026 vector.country !== undefined) {\r\n countrySet.add(String(vector.country));\r\n }\r\n}\r\n\r\nconst projects = Array.from(countrySet);\r\n","IsDeferred":false},{"Name":"lodash v2","Code":"const projects = _.chain(vectors)\r\n .uniqBy(\u0027country\u0027)\r\n .filter(p =\u003E p.country === \u0022India\u0022 \u0026\u0026 p.country !== undefined)\r\n .map(p =\u003E String(p.country))\r\n .value();","IsDeferred":false}]}