Answers for "remove duplicate objects in array typescript"

1

remove duplicates objects from array angular

this.item = this.item.filter((el, i, a) => i === a.indexOf(el))
Posted by: Guest on June-14-2021
1

remove duplicate objects based on id from array angular 8

function getUnique(arr, comp) {

                    // store the comparison  values in array
   const unique =  arr.map(e => e[comp])

                  // store the indexes of the unique objects
                  .map((e, i, final) => final.indexOf(e) === i && i)

                  // eliminate the false indexes & return unique objects
                 .filter((e) => arr[e]).map(e => arr[e]);

   return unique;
}

console.log(getUnique(arr,'id'));
Posted by: Guest on November-09-2020
0

how to check duplicate objects in array and remove in angular

var filterArray = courseArray.reduce((accumalator, current) => {
    if(!accumalator.some(item => item.id === current.id && item.name === current.name)) {
      accumalator.push(current);
    }
    return accumalator;
},[]);
console.log(filterArray)
Posted by: Guest on June-18-2021

Code answers related to "remove duplicate objects in array typescript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language