code to remove duplicates from an array code example
Example 1: remove duplicates from array
let chars = ['A', 'B', 'A', 'C', 'B'];
let uniqueChars = [...new Set(chars)];
console.log(uniqueChars);
output:
[ 'A', 'B', 'C' ]
Example 2: remove duplicates in array
uniq = [...new Set(array)];
or
uniqueArray = a.filter(function(item, pos) {
return a.indexOf(item) == pos;
})