you can use the native method Array.prototype.filter to loop through an array and leave only entries that pass a given callback function.
In the following example, our callback checks if the given value occurs in the array. If it does, it is a duplicate and will not be copied to the resulting array.
['a', 1, 2, '1']
you can also use the Set object. This object lets you store unique values of any type, whether primitive values or object references:
['q', 2, 'b', '2', 'r']