Updated on Kisan Patel
You can easily remove duplicates from an array by converting it to a set and back to an array in JavaScript.
Example:
//An Array with duplicated elements const cities = ['London', 'New York', 'Mumbai', 'New York']; //The set will automatically remove duplicates const citiesSet = new Set(cities); //Create back an array const uniqueCities = Array.from(citiesSet);