remove duplicates from array in typescript code example
Example 1: javascript remove duplicate in arrays
function removeDuplicates(array) {
return array.filter((a, b) => array.indexOf(a) === b)
};
function removeDuplicates(array) {
let x = {};
array.forEach(function(i) {
if(!x[i]) {
x[i] = true
}
})
return Object.keys(x)
};
function removeDuplicates(array) {
array.splice(0, array.length, ...(new Set(array)))
};
function removeDuplicates(array) {
let a = []
array.map(x =>
if(!a.includes(x) {
a.push(x)
})
return a
};
/THIS SITE/ "https://dev.to/mshin1995/back-to-basics-removing-duplicates-from-an-array-55he#comments"
Example 2: remove duplicates from array javascript
arr.filter((v,i,a)=>a.findIndex(t=>(t.place === v.place && t.name===v.name))===i)