javascript remove duplicate string from array 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 to remove duplicates from an array
uniqueArray = a.filter(function(item, pos) {
return a.indexOf(item) == pos;
})
Example 3: remove duplicates from array javascript
arr.filter((v,i,a)=>a.findIndex(t=>(t.place === v.place && t.name===v.name))===i)
Example 4: removing duplicates from array javascript
var names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];
var uniqueNames = [];
$.each(names, function(i, el){
if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
});