If you have an array of items that contains duplicates, you can remove them all by spreading the array into a new Set
.
- Code language
- javascript
const array = ['Hello', 'Hi', 'Hello', 'Ciao']; const filtered = [...new Set(array)]; console.log(filtered); // ['Hello', 'Hi', 'Ciao']