javascript filter remove duplicate code example
Example 1: js delete duplicates from array
const names = ['John', 'Paul', 'George', 'Ringo', 'John'];
let unique = [...new Set(names)];
console.log(unique); // 'John', 'Paul', 'George', 'Ringo'
Example 2: remove duplicates array.filter
// removeDuplicates ES6
const uniqueArray = oldArray.filter((item, index, self) => self.indexOf(item) === index);