How To Remove Duplicates In Array With Set
Elements in a Set object have to be unique. You can use this to remove duplicate Array elements like so:
> const arrayWithDuplicates = ['one', 'two', 'two', 'three', 'two']
> [...new Set(arrayWithDuplicates)]
[ 'one', 'two', 'three' ]
I have written a whole tutorial on how to remove items from an array in JavaScript.
Posted on CuteMachine in javascript.
Written by Jo who lives and works in Frankfurt building digital doodah. Stalk him on Twitter.