remove the non duplicate items 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 duplicate value from array

let chars = ['A', 'B', 'A', 'C', 'B'];
let uniqueChars = [...new Set(chars)];

console.log(uniqueChars);

Example 3: remove duplicates in array

uniq = [...new Set(array)];

or 

uniqueArray = a.filter(function(item, pos) {
    return a.indexOf(item) == pos;
})