how to remove duplicates from array in javascript using for loop code example
Example 1: js delete duplicates from array
const names = ['John', 'Paul', 'George', 'Ringo', 'John'];
let unique = [...new Set(names)];
console.log(unique);
Example 2: javascript remove duplicates from array
const initialArray = ['a', 'a', 'b',]
finalArray = Array.from(new Set(initialArray));
Example 3: javascript to remove duplicates from an array
uniqueArray = a.filter(function(item, pos) {
return a.indexOf(item) == pos;
})